Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# 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
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"
# 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
- 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"