diff --git a/.github/actions/deploy-to-github-pages/action.yml b/.github/actions/deploy-to-github-pages/action.yml index 9c77a5eada..df1ac7bf61 100644 --- a/.github/actions/deploy-to-github-pages/action.yml +++ b/.github/actions/deploy-to-github-pages/action.yml @@ -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 @@ -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 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b4b55aa8f0..32ba851ada 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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 }} diff --git a/.github/workflows/update-book.yml b/.github/workflows/update-book.yml index fd8f7458fa..6dd5169159 100644 --- a/.github/workflows/update-book.yml +++ b/.github/workflows/update-book.yml @@ -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 }} diff --git a/.github/workflows/update-download-data.yml b/.github/workflows/update-download-data.yml index f5738717bb..f434e7f257 100644 --- a/.github/workflows/update-download-data.yml +++ b/.github/workflows/update-download-data.yml @@ -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 }} diff --git a/.github/workflows/update-git-version-and-manual-pages.yml b/.github/workflows/update-git-version-and-manual-pages.yml index 7a03ab65ed..597e6b63ca 100644 --- a/.github/workflows/update-git-version-and-manual-pages.yml +++ b/.github/workflows/update-git-version-and-manual-pages.yml @@ -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 }} diff --git a/.github/workflows/update-translated-manual-pages.yml b/.github/workflows/update-translated-manual-pages.yml index 8293c7f637..0c16174018 100644 --- a/.github/workflows/update-translated-manual-pages.yml +++ b/.github/workflows/update-translated-manual-pages.yml @@ -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 }}