Skip to content

Commit

Permalink
Merge pull request #1896 from git/ttaylorr/purge-cache-via-curl
Browse files Browse the repository at this point in the history
.github/actions/deploy-to-github-pages: use Cloudflare API directly
  • Loading branch information
dscho authored Oct 6, 2024
2 parents ea707c4 + a641435 commit b4a9f8b
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 6 deletions.
19 changes: 19 additions & 0 deletions .github/actions/deploy-to-github-pages/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ inputs:
description: The GitHub token used to create an authenticated client
default: ${{ github.token }}
required: true
cloudflare-token:
description: The Cloudflare API token used to purge Cloudflare caches.
required: false
cloudflare-zone:
description: The Cloudflare zone to purge.
required: false
outputs:
url:
description: The URL to which the site was deployed
Expand Down Expand Up @@ -87,6 +93,19 @@ runs:
id: deploy
uses: actions/deploy-pages@v4

- name: Purge Cloudflare cache
id: cloudflare
shell: bash
env:
CLOUDFLARE_ZONE: ${{ inputs.cloudflare-zone }}
CLOUDFLARE_TOKEN: ${{ inputs.cloudflare-token }}
if: env.CLOUDFLARE_TOKEN != ''
run: |
curl "https://api.cloudflare.com/client/v4/zones/$CLOUDFLARE_ZONE/purge_cache" \
-H "Authorization: Bearer $CLOUDFLARE_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "purge_everything": true }'
- name: construct `--remap` option for lychee
id: remap
shell: bash
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ jobs:
- name: deploy to GitHub Pages
id: deploy
uses: ./.github/actions/deploy-to-github-pages
- name: Purge Cloudflare cache
env:
CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_ZONE }}
CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }}
if: env.CLOUDFLARE_TOKEN != ''
uses: jakejarvis/[email protected]
with:
cloudflare-token: ${{ secrets.CLOUDFLARE_TOKEN }}
cloudflare-zone: ${{ secrets.CLOUDFLARE_ZONE }}
3 changes: 3 additions & 0 deletions .github/workflows/update-book.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,6 @@ jobs:
- name: deploy to GitHub Pages
id: deploy
uses: ./.github/actions/deploy-to-github-pages
with:
cloudflare-token: ${{ secrets.CLOUDFLARE_TOKEN }}
cloudflare-zone: ${{ secrets.CLOUDFLARE_ZONE }}
3 changes: 3 additions & 0 deletions .github/workflows/update-download-data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,6 @@ jobs:
if: steps.commit.outputs.result != ''
id: deploy
uses: ./.github/actions/deploy-to-github-pages
with:
cloudflare-token: ${{ secrets.CLOUDFLARE_TOKEN }}
cloudflare-zone: ${{ secrets.CLOUDFLARE_ZONE }}
3 changes: 3 additions & 0 deletions .github/workflows/update-git-version-and-manual-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,6 @@ jobs:
if: steps.commit.outputs.result != '' || steps.manual-pages.outputs.result != ''
id: deploy
uses: ./.github/actions/deploy-to-github-pages
with:
cloudflare-token: ${{ secrets.CLOUDFLARE_TOKEN }}
cloudflare-zone: ${{ secrets.CLOUDFLARE_ZONE }}
3 changes: 3 additions & 0 deletions .github/workflows/update-translated-manual-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,6 @@ jobs:
if: steps.manual-pages.outputs.result != ''
id: deploy
uses: ./.github/actions/deploy-to-github-pages
with:
cloudflare-token: ${{ secrets.CLOUDFLARE_TOKEN }}
cloudflare-zone: ${{ secrets.CLOUDFLARE_ZONE }}

0 comments on commit b4a9f8b

Please sign in to comment.