From a5c79745d4d87e1024f01548a4116fb928b97c4c Mon Sep 17 00:00:00 2001 From: James Conway <148910373+jamesconwaydev@users.noreply.github.com> Date: Sat, 28 Nov 2026 22:23:56 -0700 Subject: [PATCH 1/3] ci: parsec.tools only changed when someone deployed it by hand Cloudflare Pages can't read this repo through its GitHub app (it fails to list the branches), so the sites were uploaded with wrangler after each merge. A workflow now builds and checks both apps on every push and pull request, deploys main to production and each pull request to a preview named after its branch. Pull requests from forks have no token, so they build without deploying. --- .github/workflows/deploy.yml | 66 ++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..56d5565 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,66 @@ +# Builds both sites on every push and pull request, and deploys them to +# Cloudflare Pages: main to parsec.tools and docs.parsec.tools, each pull +# request to a preview named after its branch. +name: deploy + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +concurrency: + group: deploy-${{ github.ref }} + cancel-in-progress: true + +jobs: + deploy: + runs-on: ubuntu-latest + timeout-minutes: 20 + env: + CLOUDFLARE_ACCOUNT_ID: 80f75c7b4d6941828d3d8cb4dc5f5ceb + # A pull request from a fork has no secrets, so it builds but doesn't deploy. + HAS_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN != '' }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1 + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version-file: .node-version + cache: pnpm + # The preview's name, from the branch name with anything but letters, + # digits and hyphens made a hyphen, so it can't reach a shell. + - name: Branch to deploy as + env: + HEAD_REF: ${{ github.event_name == 'pull_request' && github.head_ref || 'main' }} + run: echo "BRANCH=$(printf '%s' "$HEAD_REF" | tr -c 'A-Za-z0-9-' '-')" >> "$GITHUB_ENV" + - run: pnpm install --frozen-lockfile + - run: pnpm build + - run: pnpm check + - name: Deploy parsec.tools + if: env.HAS_TOKEN == 'true' + id: site + uses: cloudflare/wrangler-action@953926a2e2182532811c01a25e53647d93bf07c0 # v4.1.3 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ env.CLOUDFLARE_ACCOUNT_ID }} + command: pages deploy apps/site/dist --project-name=parsec-site --branch=${{ env.BRANCH }} --commit-dirty=true + - name: Deploy docs.parsec.tools + if: env.HAS_TOKEN == 'true' + id: docs + uses: cloudflare/wrangler-action@953926a2e2182532811c01a25e53647d93bf07c0 # v4.1.3 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ env.CLOUDFLARE_ACCOUNT_ID }} + command: pages deploy apps/docs/dist --project-name=parsec-docs --branch=${{ env.BRANCH }} --commit-dirty=true + - name: Where it went + if: env.HAS_TOKEN == 'true' + env: + SITE: ${{ steps.site.outputs.deployment-url }} + DOCS: ${{ steps.docs.outputs.deployment-url }} + run: | + printf '| Site | URL |\n|---|---|\n| parsec.tools | %s |\n| docs.parsec.tools | %s |\n' "$SITE" "$DOCS" >> "$GITHUB_STEP_SUMMARY" From 2a334359a3f21d86dce9ddb8acd9e9fe5d5ce5f4 Mon Sep 17 00:00:00 2001 From: James Conway <148910373+jamesconwaydev@users.noreply.github.com> Date: Sat, 28 Nov 2026 22:30:35 -0700 Subject: [PATCH 2/3] ci: run the deploy workflow with the token in place From edb4b458f302c97dbb8d39876e8ec20cbe10c1d7 Mon Sep 17 00:00:00 2001 From: James Conway <148910373+jamesconwaydev@users.noreply.github.com> Date: Sat, 28 Nov 2026 22:31:55 -0700 Subject: [PATCH 3/3] ci: check for the deploy token in a step, and say whether it's there --- .github/workflows/deploy.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 56d5565..b210c90 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -21,8 +21,6 @@ jobs: timeout-minutes: 20 env: CLOUDFLARE_ACCOUNT_ID: 80f75c7b4d6941828d3d8cb4dc5f5ceb - # A pull request from a fork has no secrets, so it builds but doesn't deploy. - HAS_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN != '' }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -38,6 +36,12 @@ jobs: env: HEAD_REF: ${{ github.event_name == 'pull_request' && github.head_ref || 'main' }} run: echo "BRANCH=$(printf '%s' "$HEAD_REF" | tr -c 'A-Za-z0-9-' '-')" >> "$GITHUB_ENV" + # A pull request from a fork has no secrets, so it builds but doesn't deploy. + - name: Whether there's a token to deploy with + env: + TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + run: | + if [ -n "$TOKEN" ]; then echo "HAS_TOKEN=true" >> "$GITHUB_ENV"; echo "token: set"; else echo "token: missing"; fi - run: pnpm install --frozen-lockfile - run: pnpm build - run: pnpm check