@@ -5,12 +5,12 @@ name: Deploy
55# push, no pull_request, no workflow_dispatch. Publishing the release is the
66# one and only "go live" action for this site.
77#
8- # The Cloudflare Pages project (cryptos-pki-www) and its custom domains
9- # (cryptos-pki.com, www.cryptos-pki.com) are created by hand in the
10- # Cloudflare dashboard, not by this workflow -- see README.md. The org
11- # secrets CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID must hold real
12- # values before the first release is published; this workflow never prints
13- # either one.
8+ # The workflow creates the Cloudflare Pages project (cryptos-pki-www) the
9+ # first time, when it doesn't exist yet. Its custom domains (cryptos-pki.com,
10+ # www.cryptos-pki.com) are still attached once by hand in the Cloudflare
11+ # dashboard -- see docs/deploy.md. The org secrets CLOUDFLARE_API_TOKEN and
12+ # CLOUDFLARE_ACCOUNT_ID must hold real values before the first release is
13+ # published; this workflow never prints either one.
1414on :
1515 release :
1616 types : [published]
4949 - name : Build (prerender)
5050 run : npm run build
5151
52+ - name : List the Cloudflare Pages projects
53+ id : projects
54+ uses : cloudflare/wrangler-action@953926a2e2182532811c01a25e53647d93bf07c0 # v4.1.3
55+ with :
56+ apiToken : ${{ secrets.CLOUDFLARE_API_TOKEN }}
57+ accountId : ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
58+ command : pages project list --json
59+
60+ # Checked first so every release can run this step safely: the project
61+ # is created once, on the first deploy, and left alone after that.
62+ - name : Check for the cryptos-pki-www project
63+ id : exists
64+ env :
65+ PROJECTS : ${{ steps.projects.outputs.command-output }}
66+ run : |
67+ set -euo pipefail
68+ # Wrangler may print its banner ahead of the JSON array.
69+ if printf '%s\n' "$PROJECTS" | sed -n '/^\[/,$p' | jq -e 'any(.[]; ."Project Name" == "cryptos-pki-www")' >/dev/null; then
70+ echo "found=true" >> "$GITHUB_OUTPUT"
71+ else
72+ echo "found=false" >> "$GITHUB_OUTPUT"
73+ fi
74+
75+ - name : Create the cryptos-pki-www project
76+ if : steps.exists.outputs.found == 'false'
77+ uses : cloudflare/wrangler-action@953926a2e2182532811c01a25e53647d93bf07c0 # v4.1.3
78+ with :
79+ apiToken : ${{ secrets.CLOUDFLARE_API_TOKEN }}
80+ accountId : ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
81+ command : pages project create cryptos-pki-www --production-branch=main
82+
5283 - name : Deploy build/client to Cloudflare Pages
5384 uses : cloudflare/wrangler-action@953926a2e2182532811c01a25e53647d93bf07c0 # v4.1.3
5485 with :
0 commit comments