Skip to content

Commit

Permalink
Updated update cf url workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mortyr45 committed Nov 15, 2023
1 parent 78755fd commit 640bc75
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions .github/workflows/update_cf_url.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ jobs:
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" \
NEW_URL_PATTERN='https://pacman.kovacsmiki.com/x86_64/*'
NEW_SETTINGS="{\"forwarding_url\": {\"url\": \"https://github.com/mortyr45/pacman-repository/releases/download/${{ github.event.release.name }}/\$1\", \"status_code\": 301}}"
DATA="{\"targets\": [{\"target\": \"url\", \"constraint\": {\"operator\": \"matches\", \"value\": \"$NEW_URL_PATTERN\"}}], \"actions\": [\"$NEW_SETTINGS\"], \"priority\": 1, \"status\": \"active\"}"
curl -X PUT "https://api.cloudflare.com/client/v4/zones/${{ secrets.CF_ZONE_ID }}/pagerules/${{ secrets.CF_PAGE_RULE_ID }}" \
-H "X-Auth-Key: ${{ secrets.CF_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"}'
--data "$DATA"

0 comments on commit 640bc75

Please sign in to comment.