The best way to control Claude Code, Codex and more from any computer or phone
| 1 | name: Deploy relay preview |
| 2 | |
| 3 | # Labeling a same-repository PR `relay:preview` deploys Alchemy stage `pr-<n>`. |
| 4 | # This job runs the PR's own code with account credentials, so it waits for an |
| 5 | # approval in the `relay-preview` environment on every run. Teardown is in |
| 6 | # relay-preview-cleanup.yml and never runs PR code. |
| 7 | on: |
| 8 | pull_request: |
| 9 | types: [labeled, synchronize, reopened] |
| 10 | |
| 11 | permissions: |
| 12 | contents: read |
| 13 | pull-requests: read |
| 14 | |
| 15 | concurrency: |
| 16 | group: relay-preview-${{ github.event.pull_request.number }} |
| 17 | cancel-in-progress: false |
| 18 | |
| 19 | jobs: |
| 20 | deploy_preview: |
| 21 | name: Deploy relay preview |
| 22 | if: >- |
| 23 | github.event.pull_request.head.repo.full_name == github.repository && |
| 24 | contains(github.event.pull_request.labels.*.name, 'relay:preview') |
| 25 | runs-on: blacksmith-8vcpu-ubuntu-2404 |
| 26 | timeout-minutes: 20 |
| 27 | environment: |
| 28 | name: relay-preview |
| 29 | env: |
| 30 | STAGE: pr-${{ github.event.pull_request.number }} |
| 31 | CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }} |
| 32 | PLANETSCALE_ORGANIZATION: ${{ vars.PLANETSCALE_ORGANIZATION }} |
| 33 | AXIOM_ORG_ID: ${{ vars.AXIOM_ORG_ID }} |
| 34 | RELAY_API_ZONE_NAME: ${{ vars.RELAY_API_ZONE_NAME }} |
| 35 | RELAY_TUNNEL_ZONE_NAME: ${{ vars.RELAY_TUNNEL_ZONE_NAME }} |
| 36 | CLERK_PUBLISHABLE_KEY: ${{ vars.CLERK_PUBLISHABLE_KEY }} |
| 37 | CLERK_JWT_AUDIENCE: ${{ vars.CLERK_JWT_AUDIENCE }} |
| 38 | # Previews take no alert notifier, no tunnel cleanup, and no custom |
| 39 | # domain, so they stay silent and reap nothing outside their own stage. |
| 40 | APNS_ENABLED: "false" |
| 41 | ALCHEMY_TELEMETRY_DISABLED: "1" |
| 42 | steps: |
| 43 | - name: Confirm the PR is still open and labeled |
| 44 | env: |
| 45 | GH_TOKEN: ${{ github.token }} |
| 46 | PR_NUMBER: ${{ github.event.pull_request.number }} |
| 47 | run: | |
| 48 | state=$(gh pr view "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" --json state,labels \ |
| 49 | --jq 'if .state == "OPEN" and any(.labels[]; .name == "relay:preview") then "ok" else "stale" end') |
| 50 | if [ "$state" != "ok" ]; then |
| 51 | echo "PR #$PR_NUMBER is no longer open with relay:preview; not deploying." >&2 |
| 52 | exit 1 |
| 53 | fi |
| 54 | |
| 55 | - name: Checkout |
| 56 | uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 |
| 57 | with: |
| 58 | ref: ${{ github.event.pull_request.head.sha }} |
| 59 | sparse-checkout: | |
| 60 | /* |
| 61 | !/.repos/ |
| 62 | sparse-checkout-cone-mode: false |
| 63 | |
| 64 | - name: Setup Vite+ |
| 65 | uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1.15.0 |
| 66 | with: |
| 67 | node-version-file: package.json |
| 68 | cache: true |
| 69 | run-install: | |
| 70 | args: |
| 71 | - --filter=t3code-relay... |
| 72 | |
| 73 | - name: Deploy preview stage |
| 74 | run: vp run --filter t3code-relay deploy --stage "$STAGE" --yes --no-input |
| 75 | env: |
| 76 | T3CODE_RELAY_CLIENT_CONFIG_ENV: ${{ runner.temp }}/relay-client-config.env |
| 77 | CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} |
| 78 | PLANETSCALE_API_TOKEN_ID: ${{ secrets.PLANETSCALE_API_TOKEN_ID }} |
| 79 | PLANETSCALE_API_TOKEN: ${{ secrets.PLANETSCALE_API_TOKEN }} |
| 80 | AXIOM_TOKEN: ${{ secrets.AXIOM_TOKEN }} |
| 81 | CLERK_SECRET_KEY: ${{ secrets.CLERK_SECRET_KEY }} |
| 82 | # Unset by default, so previews keep the T3 Chat link off. |
| 83 | T3CHAT_LINK_SECRET: ${{ secrets.T3CHAT_LINK_SECRET }} |