-
Notifications
You must be signed in to change notification settings - Fork 3.8k
75 lines (66 loc) · 2.68 KB
/
Copy pathdeploy-trigger-dev.yml
File metadata and controls
75 lines (66 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Deploy Dev Tasks
# Independent of app CI: task packaging and deployment must never delay dev images.
on:
push:
branches: [dev]
permissions:
contents: read
# Serialize promotions without cancelling an external deployment in flight.
# Pending pushes coalesce to the newest run while the current run finishes.
concurrency:
group: deploy-trigger-dev
cancel-in-progress: false
jobs:
deploy:
name: Deploy Trigger.dev preview
runs-on: ${{ (vars.CI_PROVIDER == '' || vars.CI_PROVIDER == 'blacksmith') && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-latest' }}
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
bun-version: 1.4.2
- name: Cache Bun dependencies
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: |
~/.bun/install/cache
node_modules
**/node_modules
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }}
restore-keys: |
${{ runner.os }}-bun-
- name: Install dependencies
run: bun install --frozen-lockfile --ignore-scripts
- name: Upload preview version
id: deploy
working-directory: ./apps/sim
env:
TRIGGER_ACCESS_TOKEN: ${{ secrets.TRIGGER_ACCESS_TOKEN }}
TRIGGER_PROJECT_ID: ${{ secrets.TRIGGER_PROJECT_ID }}
run: |
set -euo pipefail
: "${TRIGGER_ACCESS_TOKEN:?TRIGGER_ACCESS_TOKEN must be configured}"
: "${TRIGGER_PROJECT_ID:?TRIGGER_PROJECT_ID must be configured}"
bunx trigger.dev@4.5.16 deploy --env preview --branch dev-sim --skip-promotion
- name: Promote current dev preview
working-directory: ./apps/sim
env:
GH_TOKEN: ${{ github.token }}
TRIGGER_ACCESS_TOKEN: ${{ secrets.TRIGGER_ACCESS_TOKEN }}
TRIGGER_PROJECT_ID: ${{ secrets.TRIGGER_PROJECT_ID }}
VERSION: ${{ steps.deploy.outputs.deploymentVersion }}
run: |
set -euo pipefail
if ! [[ "$VERSION" =~ ^[0-9]{8}\.[0-9]+$ ]]; then
echo "ERROR: Trigger.dev did not report a valid deploymentVersion output" >&2
exit 1
fi
CURRENT_SHA=$(gh api "repos/$GITHUB_REPOSITORY/git/ref/heads/dev" --jq '.object.sha')
if [ "$CURRENT_SHA" != "$GITHUB_SHA" ]; then
echo "::notice::Skipping superseded dev task version $VERSION"
exit 0
fi
bunx trigger.dev@4.5.16 promote "$VERSION" --env preview --branch dev-sim