Fix Worker Route #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Fix Worker Route | |
| on: | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| fix-route: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Fix Worker Route | |
| env: | |
| CF_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| run: | | |
| set -x | |
| ZONE_ID="5b3f8237bfa2518bff375eb8163623a5" | |
| # Get existing routes | |
| ROUTES=$(curl -s -H "Authorization: Bearer $CF_API_TOKEN" \ | |
| "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/workers/routes") | |
| # Find the old natalie route | |
| OLD_ROUTE_ID=$(echo "$ROUTES" | jq -r '.result[] | select(.pattern | test("natalie\\.acreonetionos\\.org")) | .id') | |
| echo "Old route ID: $OLD_ROUTE_ID" | |
| # Delete the old route | |
| if [ -n "$OLD_ROUTE_ID" ] && [ "$OLD_ROUTE_ID" != "null" ]; then | |
| echo "Deleting old route..." | |
| curl -s -X DELETE \ | |
| "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/workers/routes/$OLD_ROUTE_ID" \ | |
| -H "Authorization: Bearer $CF_API_TOKEN" | jq . | |
| fi | |
| # Add new route for correct domain | |
| echo "Adding route for natalie.acreonetionos.org..." | |
| curl -s -X POST \ | |
| "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/workers/routes" \ | |
| -H "Authorization: Bearer $CF_API_TOKEN" \ | |
| -H "Content-Type: application/json" \ | |
| -d '{ | |
| "pattern": "natalie.acreonetionos.org/*", | |
| "script": "natalie-proxy" | |
| }' | jq . | |
| echo "=== Done ===" |