Skip to content

Commit 94de080

Browse files
authored
chore(ci): authenticate Trigger.dev deploys with per-environment API keys (#9423)
Map TRIGGER_ACCESS_TOKEN from TRIGGER_ACCESS_TOKEN_PROD/_STAGING/_PREVIEW, falling back to the shared TRIGGER_ACCESS_TOKEN until those secrets exist. Bump trigger.dev CLI and @trigger.dev/* to 4.7.6, the first line where promote accepts environment API keys (4.7.0) and a mismatched --env errors instead of deploying to the key's environment (4.7.5).
1 parent 5b49429 commit 94de080

4 files changed

Lines changed: 39 additions & 47 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,21 +273,21 @@ jobs:
273273
id: deploy
274274
working-directory: ./apps/sim
275275
env:
276-
TRIGGER_ACCESS_TOKEN: ${{ secrets.TRIGGER_ACCESS_TOKEN }}
276+
TRIGGER_ACCESS_TOKEN: ${{ (steps.target.outputs.environment == 'prod' && secrets.TRIGGER_ACCESS_TOKEN_PROD) || (steps.target.outputs.environment == 'staging' && secrets.TRIGGER_ACCESS_TOKEN_STAGING) || secrets.TRIGGER_ACCESS_TOKEN }}
277277
TRIGGER_PROJECT_ID: ${{ secrets.TRIGGER_PROJECT_ID }}
278278
TRIGGER_ENV: ${{ steps.target.outputs.environment }}
279279
TRIGGER_BRANCH: ${{ steps.target.outputs.preview_branch }}
280280
run: |
281281
set -eo pipefail
282282
if [ -z "$TRIGGER_ACCESS_TOKEN" ] || [ -z "$TRIGGER_PROJECT_ID" ]; then
283-
echo "ERROR: TRIGGER_ACCESS_TOKEN and TRIGGER_PROJECT_ID repo secrets must both be set" >&2
283+
echo "ERROR: TRIGGER_PROJECT_ID and a Trigger.dev access token (TRIGGER_ACCESS_TOKEN_${TRIGGER_ENV^^} or TRIGGER_ACCESS_TOKEN) repo secrets must be set" >&2
284284
exit 1
285285
fi
286286
TARGET_ARGS=(--env "$TRIGGER_ENV")
287287
if [ -n "$TRIGGER_BRANCH" ]; then
288288
TARGET_ARGS+=(--branch "$TRIGGER_BRANCH")
289289
fi
290-
bunx trigger.dev@4.5.16 deploy "${TARGET_ARGS[@]}" --skip-promotion
290+
bunx trigger.dev@4.7.6 deploy "${TARGET_ARGS[@]}" --skip-promotion
291291
292292
- name: Validate deployment version output
293293
env:
@@ -618,15 +618,15 @@ jobs:
618618
- name: Promote Trigger.dev version
619619
working-directory: ./apps/sim
620620
env:
621-
TRIGGER_ACCESS_TOKEN: ${{ secrets.TRIGGER_ACCESS_TOKEN }}
621+
TRIGGER_ACCESS_TOKEN: ${{ (needs.trigger-upload.outputs.environment == 'prod' && secrets.TRIGGER_ACCESS_TOKEN_PROD) || (needs.trigger-upload.outputs.environment == 'staging' && secrets.TRIGGER_ACCESS_TOKEN_STAGING) || secrets.TRIGGER_ACCESS_TOKEN }}
622622
TRIGGER_PROJECT_ID: ${{ secrets.TRIGGER_PROJECT_ID }}
623623
TRIGGER_ENV: ${{ needs.trigger-upload.outputs.environment }}
624624
TRIGGER_BRANCH: ${{ needs.trigger-upload.outputs.preview_branch }}
625625
VERSION: ${{ needs.trigger-upload.outputs.version }}
626626
run: |
627627
set -eo pipefail
628628
if [ -z "$TRIGGER_ACCESS_TOKEN" ] || [ -z "$TRIGGER_PROJECT_ID" ]; then
629-
echo "ERROR: TRIGGER_ACCESS_TOKEN and TRIGGER_PROJECT_ID repo secrets must both be set" >&2
629+
echo "ERROR: TRIGGER_PROJECT_ID and a Trigger.dev access token (TRIGGER_ACCESS_TOKEN_${TRIGGER_ENV^^} or TRIGGER_ACCESS_TOKEN) repo secrets must be set" >&2
630630
exit 1
631631
fi
632632
if [ -z "$VERSION" ]; then
@@ -638,7 +638,7 @@ jobs:
638638
if [ -n "$TRIGGER_BRANCH" ]; then
639639
TARGET_ARGS+=(--branch "$TRIGGER_BRANCH")
640640
fi
641-
bunx trigger.dev@4.5.16 promote "$VERSION" "${TARGET_ARGS[@]}"
641+
bunx trigger.dev@4.7.6 promote "$VERSION" "${TARGET_ARGS[@]}"
642642
643643
# Production only, once the new app serves traffic: submit the library and comparison URLs this
644644
# push changed to IndexNow. Best effort: nothing depends on it, and a failure never fails the run.

‎.github/workflows/trigger-dev.yml‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,19 @@ jobs:
3535
id: deploy
3636
working-directory: ./apps/sim
3737
env:
38-
TRIGGER_ACCESS_TOKEN: ${{ secrets.TRIGGER_ACCESS_TOKEN }}
38+
TRIGGER_ACCESS_TOKEN: ${{ secrets.TRIGGER_ACCESS_TOKEN_PREVIEW || secrets.TRIGGER_ACCESS_TOKEN }}
3939
TRIGGER_PROJECT_ID: ${{ secrets.TRIGGER_PROJECT_ID }}
4040
run: |
4141
set -euo pipefail
42-
: "${TRIGGER_ACCESS_TOKEN:?TRIGGER_ACCESS_TOKEN must be configured}"
42+
: "${TRIGGER_ACCESS_TOKEN:?TRIGGER_ACCESS_TOKEN_PREVIEW or TRIGGER_ACCESS_TOKEN must be configured}"
4343
: "${TRIGGER_PROJECT_ID:?TRIGGER_PROJECT_ID must be configured}"
44-
bunx trigger.dev@4.5.16 deploy --env preview --branch dev-sim --skip-promotion
44+
bunx trigger.dev@4.7.6 deploy --env preview --branch dev-sim --skip-promotion
4545
4646
- name: Promote current dev preview
4747
working-directory: ./apps/sim
4848
env:
4949
GH_TOKEN: ${{ github.token }}
50-
TRIGGER_ACCESS_TOKEN: ${{ secrets.TRIGGER_ACCESS_TOKEN }}
50+
TRIGGER_ACCESS_TOKEN: ${{ secrets.TRIGGER_ACCESS_TOKEN_PREVIEW || secrets.TRIGGER_ACCESS_TOKEN }}
5151
TRIGGER_PROJECT_ID: ${{ secrets.TRIGGER_PROJECT_ID }}
5252
VERSION: ${{ steps.deploy.outputs.deploymentVersion }}
5353
run: |
@@ -61,4 +61,4 @@ jobs:
6161
echo "::notice::Skipping superseded dev task version $VERSION"
6262
exit 0
6363
fi
64-
bunx trigger.dev@4.5.16 promote "$VERSION" --env preview --branch dev-sim
64+
bunx trigger.dev@4.7.6 promote "$VERSION" --env preview --branch dev-sim

‎apps/sim/package.json‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@
171171
"@tiptap/starter-kit": "3.31.4",
172172
"@tiptap/suggestion": "3.31.4",
173173
"@tiptap/y-tiptap": "3.0.7",
174-
"@trigger.dev/core": "4.5.16",
175-
"@trigger.dev/sdk": "4.5.16",
174+
"@trigger.dev/core": "4.7.6",
175+
"@trigger.dev/sdk": "4.7.6",
176176
"@typescript/typescript6": "^6.0.2",
177177
"@xterm/addon-fit": "0.11.0",
178178
"@xterm/addon-unicode11": "0.9.0",
@@ -292,7 +292,7 @@
292292
"@tailwindcss/postcss": "^4.3.3",
293293
"@tailwindcss/typography": "0.5.20",
294294
"@testing-library/jest-dom": "^6.10.0",
295-
"@trigger.dev/build": "4.5.16",
295+
"@trigger.dev/build": "4.7.6",
296296
"@types/archiver": "8.0.0",
297297
"@types/busboy": "1.5.4",
298298
"@types/hast": "3.0.5",

0 commit comments

Comments
 (0)