diff --git a/.github/workflows/deploy-site.yaml b/.github/workflows/deploy-site.yaml index f5b115d..b18b585 100644 --- a/.github/workflows/deploy-site.yaml +++ b/.github/workflows/deploy-site.yaml @@ -38,8 +38,16 @@ jobs: # without hitting the anonymous GitHub API rate limit. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # wrangler pages deploy will not create a project in CI (stdin is not a + # TTY). Create "memcache" on first publish so a new site can go live. - name: Publish to Cloudflare Pages env: CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - run: pnpm exec wrangler pages deploy site/dist --project-name=memcache --branch=main --commit-dirty=true + run: | + set -euo pipefail + if ! pnpm exec wrangler pages project list --json \ + | jq -e 'any(.[]; ."Project Name" == "memcache")' >/dev/null; then + pnpm exec wrangler pages project create memcache --production-branch=main + fi + pnpm exec wrangler pages deploy site/dist --project-name=memcache --branch=main --commit-dirty=true