This action that lets you update your Cloudflare workers route pattern.
Required Your Cloudflare email id
Required Your Cloudflare API Key
Required Your Cloudflare Zone id
Required Route Id of the Worker you're trying to update
Run this command locally to get the Route Object for the workers in the Zone:
curl -X GET "https://api.cloudflare.com/client/v4/zones/${CF_ZONE_ID}/workers/routes/" \
-H "X-Auth-Email: ${CF_EMAIL}" \
-H "X-Auth-Key: ${CF_API_KEY}"
It'll give a response like below:
{
"result": [
{
"id": "route_id",
"pattern": "yourdomain.com/*",
"script": "worker-id",
"request_limit_fail_open": false
}
],
"success": true,
"errors": [],
"messages": []
}
Grab the route_id
from this response.
Required Your Cloudflare Worker Id
Required The new route pattern that you wish to update
Add all these variables to Github Secrets to not hardcode or expose them to public.
uses: actions/cloudflare-worker-route-update@v1
with:
CF_EMAIL: ${{ secrets.CF_EMAIL }}
CF_API_KEY: ${{ secrets.CF_API_KEY}}
CF_ZONE_ID: ${{ secrets.CF_ZONE_ID }}
CF_ROUTE_ID: ${{ secrets.CF_ROUTE_ID }}
CF_WORKER_NAME: ${{ secrets.CF_WORKER_NAME }}
CF_ROUTE_PATTERN: aakashgoel.me/*
MIT licensed