@@ -16,6 +16,7 @@ permissions:
1616jobs :
1717 test-build :
1818 name : Test and Build
19+ if : github.ref != 'refs/heads/dev' || github.event_name == 'pull_request'
1920 uses : ./.github/workflows/test-build.yml
2021 secrets : inherit
2122
@@ -45,11 +46,66 @@ jobs:
4546 echo "ℹ️ Not a release commit"
4647 fi
4748
48- # Build AMD64 images and push to ECR immediately (+ GHCR for main)
49+ # Dev: build all 3 images for ECR only (no GHCR, no ARM64)
50+ build-dev :
51+ name : Build Dev ECR
52+ needs : [detect-version]
53+ if : github.event_name == 'push' && github.ref == 'refs/heads/dev'
54+ runs-on : blacksmith-8vcpu-ubuntu-2404
55+ permissions :
56+ contents : read
57+ id-token : write
58+ strategy :
59+ fail-fast : false
60+ matrix :
61+ include :
62+ - dockerfile : ./docker/app.Dockerfile
63+ ecr_repo_secret : ECR_APP
64+ - dockerfile : ./docker/db.Dockerfile
65+ ecr_repo_secret : ECR_MIGRATIONS
66+ - dockerfile : ./docker/realtime.Dockerfile
67+ ecr_repo_secret : ECR_REALTIME
68+ steps :
69+ - name : Checkout code
70+ uses : actions/checkout@v4
71+
72+ - name : Configure AWS credentials
73+ uses : aws-actions/configure-aws-credentials@v4
74+ with :
75+ role-to-assume : ${{ secrets.DEV_AWS_ROLE_TO_ASSUME }}
76+ aws-region : ${{ secrets.DEV_AWS_REGION }}
77+
78+ - name : Login to Amazon ECR
79+ id : login-ecr
80+ uses : aws-actions/amazon-ecr-login@v2
81+
82+ - name : Login to Docker Hub
83+ uses : docker/login-action@v3
84+ with :
85+ username : ${{ secrets.DOCKERHUB_USERNAME }}
86+ password : ${{ secrets.DOCKERHUB_TOKEN }}
87+
88+ - name : Set up Docker Buildx
89+ uses : useblacksmith/setup-docker-builder@v1
90+
91+ - name : Build and push
92+ uses : useblacksmith/build-push-action@v2
93+ with :
94+ context : .
95+ file : ${{ matrix.dockerfile }}
96+ platforms : linux/amd64
97+ push : true
98+ tags : ${{ steps.login-ecr.outputs.registry }}/${{ secrets[matrix.ecr_repo_secret] }}:dev
99+ provenance : false
100+ sbom : false
101+
102+ # Main/staging: build AMD64 images and push to ECR + GHCR
49103 build-amd64 :
50104 name : Build AMD64
51105 needs : [test-build, detect-version]
52- if : github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/dev')
106+ if : >-
107+ github.event_name == 'push' &&
108+ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging')
53109 runs-on : blacksmith-8vcpu-ubuntu-2404
54110 permissions :
55111 contents : read
75131 - name : Configure AWS credentials
76132 uses : aws-actions/configure-aws-credentials@v4
77133 with :
78- role-to-assume : ${{ github.ref == 'refs/heads/main' && secrets.AWS_ROLE_TO_ASSUME || github.ref == 'refs/heads/dev' && secrets.DEV_AWS_ROLE_TO_ASSUME || secrets.STAGING_AWS_ROLE_TO_ASSUME }}
79- aws-region : ${{ github.ref == 'refs/heads/main' && secrets.AWS_REGION || github.ref == 'refs/heads/dev' && secrets.DEV_AWS_REGION || secrets.STAGING_AWS_REGION }}
134+ role-to-assume : ${{ github.ref == 'refs/heads/main' && secrets.AWS_ROLE_TO_ASSUME || secrets.STAGING_AWS_ROLE_TO_ASSUME }}
135+ aws-region : ${{ github.ref == 'refs/heads/main' && secrets.AWS_REGION || secrets.STAGING_AWS_REGION }}
80136
81137 - name : Login to Amazon ECR
82138 id : login-ecr
@@ -106,26 +162,20 @@ jobs:
106162 ECR_REPO="${{ secrets[matrix.ecr_repo_secret] }}"
107163 GHCR_IMAGE="${{ matrix.ghcr_image }}"
108164
109- # ECR tags (always build for ECR)
110165 if [ "${{ github.ref }}" = "refs/heads/main" ]; then
111166 ECR_TAG="latest"
112- elif [ "${{ github.ref }}" = "refs/heads/dev" ]; then
113- ECR_TAG="dev"
114167 else
115168 ECR_TAG="staging"
116169 fi
117170 ECR_IMAGE="${ECR_REGISTRY}/${ECR_REPO}:${ECR_TAG}"
118171
119- # Build tags list
120172 TAGS="${ECR_IMAGE}"
121173
122- # Add GHCR tags only for main branch
123174 if [ "${{ github.ref }}" = "refs/heads/main" ]; then
124175 GHCR_AMD64="${GHCR_IMAGE}:latest-amd64"
125176 GHCR_SHA="${GHCR_IMAGE}:${{ github.sha }}-amd64"
126177 TAGS="${TAGS},$GHCR_AMD64,$GHCR_SHA"
127178
128- # Add version tag if this is a release commit
129179 if [ "${{ needs.detect-version.outputs.is_release }}" = "true" ]; then
130180 VERSION="${{ needs.detect-version.outputs.version }}"
131181 GHCR_VERSION="${GHCR_IMAGE}:${VERSION}-amd64"
@@ -256,6 +306,14 @@ jobs:
256306 docker manifest push "${IMAGE_BASE}:${VERSION}"
257307 fi
258308
309+ # Run database migrations for dev
310+ migrate-dev :
311+ name : Migrate Dev DB
312+ needs : [build-dev]
313+ if : github.event_name == 'push' && github.ref == 'refs/heads/dev'
314+ uses : ./.github/workflows/migrations.yml
315+ secrets : inherit
316+
259317 # Check if docs changed
260318 check-docs-changes :
261319 name : Check Docs Changes
0 commit comments