Skip to content

.github/workflows/update_cf_url.yml #3

.github/workflows/update_cf_url.yml

.github/workflows/update_cf_url.yml #3

Workflow file for this run

on:
release:
types:
- published
jobs:
update_url:
runs-on: ubuntu-latest
steps:
- run: |
CLOUDFLARE_API_TOKEN=${{ secrets.CF_API_TOKEN }}
RELEASE_ID=${{ github.event.release.id }}
RELEASE_NAME=${{ github.event.release.name }}
ZONE_ID=${{ secrets.CF_ZONE_ID }}
PAGE_RULE_ID=${{ secrets.CF_PAGE_RULE_ID }}
NEW_URL_PATTERN="https://pacman.kovacsmiki.com/x86_64/*"
NEW_SETTINGS='{"forwarding_url": {"url": "https://github.com/mortyr45/pacman-repository/releases/download/'"$RELEASE_NAME"'/$1", "status_code": 301}}'
curl -X PUT "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/pagerules/$PAGE_RULE_ID" \
-H "X-Auth-Key: $CLOUDFLARE_API_TOKEN" \
-H "Content-Type: application/json" \
--data '{"targets": [{"target": "url", "constraint": {"operator": "matches", "value": "'"$NEW_URL_PATTERN"'"}}], "actions": ['"$NEW_SETTINGS"'], "priority": 1, "status": "active"}'