1name: Deploy T3 Connect relay
2
3on:
4 push:
5 branches:
6 - main
7 # Redeploys main after a variable or secret change. Alchemy redeploys the
8 # Worker when a value it reads changes, so force is rarely needed.
9 workflow_dispatch:
10 inputs:
11 force:
12 description: Redeploy every resource, including ones with no detected changes.
13 type: boolean
14 default: false
15
16permissions:
17 contents: read
18 id-token: none
19 statuses: write
20
21concurrency:
22 group: relay-production
23 cancel-in-progress: false
24
25jobs:
26 deploy_relay:
27 name: Deploy production relay
28 # A manual run from another branch would deploy that branch to production.
29 if: github.repository == 'pingdotgg/t3code' && github.ref == 'refs/heads/main'
30 runs-on: blacksmith-8vcpu-ubuntu-2404
31 timeout-minutes: 15
32 environment:
33 name: production
34 env:
35 CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
36 PLANETSCALE_ORGANIZATION: ${{ vars.PLANETSCALE_ORGANIZATION }}
37 AXIOM_ORG_ID: ${{ vars.AXIOM_ORG_ID }}
38 RELAY_DOMAIN: ${{ vars.RELAY_DOMAIN }}
39 RELAY_API_ZONE_NAME: ${{ vars.RELAY_API_ZONE_NAME }}
40 RELAY_TUNNEL_ZONE_NAME: ${{ vars.RELAY_TUNNEL_ZONE_NAME }}
41 RELAY_TUNNEL_CLEANUP_MODE: ${{ vars.RELAY_TUNNEL_CLEANUP_MODE }}
42 RELAY_LEGACY_TUNNEL_CLEANUP_MODE: ${{ vars.RELAY_LEGACY_TUNNEL_CLEANUP_MODE }}
43 RELAY_ALERT_NOTIFIER_ID: ${{ vars.RELAY_ALERT_NOTIFIER_ID }}
44 RELAY_WARNING_NOTIFIER_ID: ${{ vars.RELAY_WARNING_NOTIFIER_ID }}
45 CLERK_PUBLISHABLE_KEY: ${{ vars.CLERK_PUBLISHABLE_KEY }}
46 CLERK_JWT_AUDIENCE: ${{ vars.CLERK_JWT_AUDIENCE }}
47 APNS_ENVIRONMENT: ${{ vars.APNS_ENVIRONMENT }}
48 APNS_TEAM_ID: ${{ vars.APNS_TEAM_ID }}
49 APNS_KEY_ID: ${{ vars.APNS_KEY_ID }}
50 APNS_BUNDLE_ID: ${{ vars.APNS_BUNDLE_ID }}
51 ALCHEMY_TELEMETRY_DISABLED: "1"
52 steps:
53 - name: Checkout
54 uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
55 with:
56 sparse-checkout: |
57 /*
58 !/.repos/
59 sparse-checkout-cone-mode: false
60
61 - name: Setup Vite+
62 uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb # v1.15.0
63 with:
64 node-version-file: package.json
65 cache: true
66 run-install: |
67 args:
68 - --filter=t3code-relay...
69
70 - name: Deploy production relay stage
71 run: vp run --filter t3code-relay deploy --stage prod --yes --no-input ${{ inputs.force && '--force' || '' }}
72 env:
73 # The PublishClientConfig action writes the client env here instead
74 # of the repo-root .env; nothing on the runner reads it.
75 T3CODE_RELAY_CLIENT_CONFIG_ENV: ${{ runner.temp }}/relay-client-config.env
76 CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
77 PLANETSCALE_API_TOKEN_ID: ${{ secrets.PLANETSCALE_API_TOKEN_ID }}
78 PLANETSCALE_API_TOKEN: ${{ secrets.PLANETSCALE_API_TOKEN }}
79 AXIOM_TOKEN: ${{ secrets.AXIOM_TOKEN }}
80 CLERK_SECRET_KEY: ${{ secrets.CLERK_SECRET_KEY }}
81 APNS_PRIVATE_KEY: ${{ secrets.APNS_PRIVATE_KEY }}
82 FCM_SERVICE_ACCOUNT: ${{ secrets.FCM_SERVICE_ACCOUNT }}
83 T3CHAT_LINK_SECRET: ${{ secrets.T3CHAT_LINK_SECRET }}
84
85 - name: Publish relay deploy commit status
86 uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
87 with:
88 script: |
89 await github.rest.repos.createCommitStatus({
90 owner: context.repo.owner,
91 repo: context.repo.repo,
92 sha: context.sha,
93 state: "success",
94 context: "Relay deploy / production",
95 description: "Relay production deploy completed.",
96 target_url: `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`,
97 });