feat: add notify telegram & bark, and some minor fixes
This commit is contained in:
1 parent
63be746b4d
commit
0c6556eda9
6 files changed
+174
-40
No files matched your search
@@ -22,16 +22,21 @@ jobs:
|
||||
cache: 'npm'
|
||||
|
||||
# Automatically get an account id via the API Token
|
||||
# if secrets.CLOUDFLARE_ACCOUNT_ID is not set.
|
||||
- name: Fetch Account ID
|
||||
id: fetch_account_id
|
||||
run: |
|
||||
ACCOUNT_ID=$(curl -X GET "https://api.cloudflare.com/client/v4/accounts" -H "Authorization: Bearer "$CLOUDFLARE_API_TOKEN -H "Content-Type:application/json" | jq ".result[0].id" -r)
|
||||
if [[ "$ACCOUNT_ID" == "null" ]]; then
|
||||
echo "Failed to get an account id, please make sure you have set up CLOUDFLARE_API_TOKEN correctly!"
|
||||
exit 1
|
||||
if [[ -n "${{ secrets.CLOUDFLARE_ACCOUNT_ID }}" ]]; then
|
||||
ACCOUNT_ID="${{ secrets.CLOUDFLARE_ACCOUNT_ID }}"
|
||||
echo "Using provided CLOUDFLARE_ACCOUNT_ID from secrets."
|
||||
else
|
||||
echo 'account_id='$ACCOUNT_ID >> $GITHUB_OUTPUT
|
||||
ACCOUNT_ID=$(curl -X GET "https://api.cloudflare.com/client/v4/accounts" -H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" -H "Content-Type:application/json" | jq ".result[0].id" -r)
|
||||
if [[ "$ACCOUNT_ID" == "null" ]]; then
|
||||
echo "Failed to get an account id, please make sure you have set up CLOUDFLARE_API_TOKEN correctly!"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
echo 'account_id='$ACCOUNT_ID >> $GITHUB_OUTPUT
|
||||
|
||||
env:
|
||||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
@@ -56,13 +61,13 @@ jobs:
|
||||
# since we didn't setup a remote backend to store state,
|
||||
# following runs will fail with name conflict, which is normal.
|
||||
continue-on-error: true
|
||||
|
||||
|
||||
run: |
|
||||
terraform init
|
||||
terraform apply -auto-approve -input=false
|
||||
env:
|
||||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
TF_VAR_CLOUDFLARE_ACCOUNT_ID: ${{ steps.fetch_account_id.outputs.account_id }}
|
||||
TF_VAR_CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID || steps.fetch_account_id.outputs.account_id }}
|
||||
|
||||
# Still need to upload worker to keep it up-to-date (Terraform will fail after first-time setup)
|
||||
- name: Upload worker
|
||||
@@ -70,7 +75,7 @@ jobs:
|
||||
curl --fail-with-body -X PUT https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/workers/scripts/uptimeflare_worker/content --header 'Authorization: Bearer '$CLOUDFLARE_API_TOKEN -F 'index.js=@worker/dist/index.js;type=application/javascript+module' -F 'metadata={"main_module": "index.js"}'
|
||||
env:
|
||||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
CLOUDFLARE_ACCOUNT_ID: ${{ steps.fetch_account_id.outputs.account_id }}
|
||||
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID || steps.fetch_account_id.outputs.account_id }}
|
||||
|
||||
# Currently Terraform Cloudflare provider doesn't support direct upload, use wrangler to upload instead.
|
||||
- name: Upload pages
|
||||
@@ -78,3 +83,4 @@ jobs:
|
||||
npx wrangler pages deploy .vercel/output/static --project-name uptimeflare
|
||||
env:
|
||||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID || steps.fetch_account_id.outputs.account_id }}
|
||||
Reference in new issue
Block a user