Skip to content

Commit 87c00ce

Browse files
authored
improvement(ci): trigger.dev pushes (#1506)
* Fix trigger workflow ci * Update trigger location
1 parent 17edf04 commit 87c00ce

File tree

1 file changed

+183
-13
lines changed

1 file changed

+183
-13
lines changed

.github/workflows/ci.yml

Lines changed: 183 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,200 @@ jobs:
1616
uses: ./.github/workflows/test-build.yml
1717
secrets: inherit
1818

19-
# Build and push images (ECR for staging, ECR + GHCR for main)
20-
build-images:
21-
name: Build Images
19+
# Deploy Trigger.dev FIRST (right after test-build, before images)
20+
trigger-deploy:
21+
name: Deploy Trigger.dev
2222
needs: test-build
2323
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging')
24-
uses: ./.github/workflows/images.yml
24+
uses: ./.github/workflows/trigger-deploy.yml
2525
secrets: inherit
26+
27+
# Build AMD64 images and push to ECR immediately (+ GHCR for main)
28+
build-amd64:
29+
name: Build AMD64
30+
needs: trigger-deploy
31+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging')
32+
runs-on: blacksmith-4vcpu-ubuntu-2404
2633
permissions:
2734
contents: read
2835
packages: write
2936
id-token: write
37+
strategy:
38+
fail-fast: false
39+
matrix:
40+
include:
41+
- dockerfile: ./docker/app.Dockerfile
42+
ghcr_image: ghcr.io/simstudioai/simstudio
43+
ecr_repo_secret: ECR_APP
44+
- dockerfile: ./docker/db.Dockerfile
45+
ghcr_image: ghcr.io/simstudioai/migrations
46+
ecr_repo_secret: ECR_MIGRATIONS
47+
- dockerfile: ./docker/realtime.Dockerfile
48+
ghcr_image: ghcr.io/simstudioai/realtime
49+
ecr_repo_secret: ECR_REALTIME
50+
steps:
51+
- name: Checkout code
52+
uses: actions/checkout@v4
3053

31-
# Deploy Trigger.dev (after builds complete)
32-
trigger-deploy:
33-
name: Deploy Trigger.dev
34-
needs: build-images
35-
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging')
36-
uses: ./.github/workflows/trigger-deploy.yml
37-
secrets: inherit
54+
- name: Configure AWS credentials
55+
uses: aws-actions/configure-aws-credentials@v4
56+
with:
57+
role-to-assume: ${{ github.ref == 'refs/heads/main' && secrets.AWS_ROLE_TO_ASSUME || secrets.STAGING_AWS_ROLE_TO_ASSUME }}
58+
aws-region: ${{ github.ref == 'refs/heads/main' && secrets.AWS_REGION || secrets.STAGING_AWS_REGION }}
59+
60+
- name: Login to Amazon ECR
61+
id: login-ecr
62+
uses: aws-actions/amazon-ecr-login@v2
63+
64+
- name: Login to Docker Hub
65+
uses: docker/login-action@v3
66+
with:
67+
username: ${{ secrets.DOCKERHUB_USERNAME }}
68+
password: ${{ secrets.DOCKERHUB_TOKEN }}
69+
70+
- name: Login to GHCR
71+
if: github.ref == 'refs/heads/main'
72+
uses: docker/login-action@v3
73+
with:
74+
registry: ghcr.io
75+
username: ${{ github.repository_owner }}
76+
password: ${{ secrets.GITHUB_TOKEN }}
77+
78+
- name: Set up Docker Buildx
79+
uses: useblacksmith/setup-docker-builder@v1
80+
81+
- name: Generate tags
82+
id: meta
83+
run: |
84+
ECR_REGISTRY="${{ steps.login-ecr.outputs.registry }}"
85+
ECR_REPO="${{ secrets[matrix.ecr_repo_secret] }}"
86+
GHCR_IMAGE="${{ matrix.ghcr_image }}"
87+
88+
# ECR tags (always build for ECR)
89+
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
90+
ECR_TAG="latest"
91+
else
92+
ECR_TAG="staging"
93+
fi
94+
ECR_IMAGE="${ECR_REGISTRY}/${ECR_REPO}:${ECR_TAG}"
95+
96+
# Build tags list
97+
TAGS="${ECR_IMAGE}"
98+
99+
# Add GHCR tags only for main branch
100+
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
101+
GHCR_AMD64="${GHCR_IMAGE}:latest-amd64"
102+
GHCR_SHA="${GHCR_IMAGE}:${{ github.sha }}-amd64"
103+
TAGS="${TAGS},$GHCR_AMD64,$GHCR_SHA"
104+
fi
105+
106+
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
107+
108+
- name: Build and push images
109+
uses: useblacksmith/build-push-action@v2
110+
with:
111+
context: .
112+
file: ${{ matrix.dockerfile }}
113+
platforms: linux/amd64
114+
push: true
115+
tags: ${{ steps.meta.outputs.tags }}
116+
provenance: false
117+
sbom: false
118+
119+
# Build ARM64 images for GHCR (main branch only, runs in parallel)
120+
build-ghcr-arm64:
121+
name: Build ARM64 (GHCR Only)
122+
needs: trigger-deploy
123+
runs-on: linux-arm64-8-core
124+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
125+
permissions:
126+
contents: read
127+
packages: write
128+
strategy:
129+
fail-fast: false
130+
matrix:
131+
include:
132+
- dockerfile: ./docker/app.Dockerfile
133+
image: ghcr.io/simstudioai/simstudio
134+
- dockerfile: ./docker/db.Dockerfile
135+
image: ghcr.io/simstudioai/migrations
136+
- dockerfile: ./docker/realtime.Dockerfile
137+
image: ghcr.io/simstudioai/realtime
138+
139+
steps:
140+
- name: Checkout code
141+
uses: actions/checkout@v4
142+
143+
- name: Login to GHCR
144+
uses: docker/login-action@v3
145+
with:
146+
registry: ghcr.io
147+
username: ${{ github.repository_owner }}
148+
password: ${{ secrets.GITHUB_TOKEN }}
149+
150+
- name: Set up Docker Buildx
151+
uses: useblacksmith/setup-docker-builder@v1
152+
153+
- name: Generate ARM64 tags
154+
id: meta
155+
run: |
156+
IMAGE="${{ matrix.image }}"
157+
echo "tags=${IMAGE}:latest-arm64,${IMAGE}:${{ github.sha }}-arm64" >> $GITHUB_OUTPUT
158+
159+
- name: Build and push ARM64 to GHCR
160+
uses: useblacksmith/build-push-action@v2
161+
with:
162+
context: .
163+
file: ${{ matrix.dockerfile }}
164+
platforms: linux/arm64
165+
push: true
166+
tags: ${{ steps.meta.outputs.tags }}
167+
provenance: false
168+
sbom: false
169+
170+
# Create GHCR multi-arch manifests (only for main, after both builds)
171+
create-ghcr-manifests:
172+
name: Create GHCR Manifests
173+
runs-on: blacksmith-4vcpu-ubuntu-2404
174+
needs: [build-amd64, build-ghcr-arm64]
175+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
176+
permissions:
177+
packages: write
178+
strategy:
179+
matrix:
180+
include:
181+
- image: ghcr.io/simstudioai/simstudio
182+
- image: ghcr.io/simstudioai/migrations
183+
- image: ghcr.io/simstudioai/realtime
184+
185+
steps:
186+
- name: Login to GHCR
187+
uses: docker/login-action@v3
188+
with:
189+
registry: ghcr.io
190+
username: ${{ github.repository_owner }}
191+
password: ${{ secrets.GITHUB_TOKEN }}
192+
193+
- name: Create and push manifests
194+
run: |
195+
IMAGE_BASE="${{ matrix.image }}"
196+
197+
# Create latest manifest
198+
docker manifest create "${IMAGE_BASE}:latest" \
199+
"${IMAGE_BASE}:latest-amd64" \
200+
"${IMAGE_BASE}:latest-arm64"
201+
docker manifest push "${IMAGE_BASE}:latest"
202+
203+
# Create SHA manifest
204+
docker manifest create "${IMAGE_BASE}:${{ github.sha }}" \
205+
"${IMAGE_BASE}:${{ github.sha }}-amd64" \
206+
"${IMAGE_BASE}:${{ github.sha }}-arm64"
207+
docker manifest push "${IMAGE_BASE}:${{ github.sha }}"
38208
39-
# Process docs embeddings if needed
209+
# Process docs embeddings (only needs ECR images from build-amd64)
40210
process-docs:
41211
name: Process Docs
42-
needs: [build-images, trigger-deploy]
212+
needs: build-amd64
43213
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging')
44214
uses: ./.github/workflows/docs-embeddings.yml
45215
secrets: inherit

0 commit comments

Comments
 (0)