Skip to content

Commit

Permalink
.github/workflows: don't clear Cloudflare cache unless configured
Browse files Browse the repository at this point in the history
The recent change in 0d22411 (.github/workflows: purge Cloudflare
cache on deployment, 2024-10-01) will cause deployment workflows run in
forks of git/git-scm.com to fail, since they will likely not have a
Cloudflare token configured in their repository secrets.

Let's make use of a suggestion from Johannes[1] and only run this step
when the repository is configured with a Cloudflare token.

Note that we can't directly write:

    if: ${{ secrets.CLOUDFLARE_TOKEN != '' }}

, because repository secrets cannot be used in job step-level
conditionals[2]. Instead, the GitHub Actions documentation recommends
setting the secret as an environment variable, and then using the
presence (or absence) of that environment variable's contents as a proxy
to determine whether or not the secret is set.

All together, this should un-break deployment workflows in forks of
git/git-scm.com for repositories that have not set up a Cloudflare
token.

[1]: #1893 (review)
[2]: https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#example-using-secrets

Suggested-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
  • Loading branch information
ttaylorr committed Oct 2, 2024
1 parent a99bcaf commit 5cb2ac2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ jobs:
id: deploy
uses: ./.github/actions/deploy-to-github-pages
- name: Purge Cloudflare cache
env:
CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }}
if: ${{ env.CLOUDFLARE_TOKEN != '' }}
uses: jakejarvis/cloudflare-purge-action@v0.3.0
env:
CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_ZONE }}
Expand Down

0 comments on commit 5cb2ac2

Please sign in to comment.