Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.github/actions/deploy-to-github-pages: use Cloudflare API directly #1896

Merged
merged 1 commit into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/cloudflare-purge-action@v0.3.0
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 }}
Loading