Skip to content

Commit 1eb9b27

Browse files
committed
fix(ci): switch to nx container command for builds
- Replace docker/build-push-action with nx container - Use project's existing nx-container plugin configuration - Match proven pattern from artifacts.yaml workflow - Tested locally: checkout Dockerfile builds successfully
1 parent b3c3614 commit 1eb9b27

File tree

1 file changed

+27
-25
lines changed

1 file changed

+27
-25
lines changed

.github/workflows/build-push-images.yml

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -137,45 +137,47 @@ jobs:
137137
id: login-ecr
138138
uses: aws-actions/amazon-ecr-login@v2
139139

140-
- name: Extract metadata
141-
id: meta
142-
uses: docker/metadata-action@v5
140+
- name: Setup Node.js
141+
uses: actions/setup-node@v4
143142
with:
144-
images: ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REGISTRY_PREFIX }}-${{ matrix.service }}
145-
tags: |
146-
type=sha,prefix=,format=short
147-
type=raw,value=latest,enable={{is_default_branch}}
148-
type=raw,value={{date 'YYYYMMDD-HHmmss'}}
149-
type=ref,event=pr,prefix=pr-
150-
151-
- name: Build and push Docker image
152-
uses: docker/build-push-action@v5
153-
with:
154-
context: src/${{ matrix.service }}
155-
file: src/${{ matrix.service }}/Dockerfile
156-
platforms: linux/amd64,linux/arm64
157-
push: ${{ github.event_name != 'pull_request' }}
158-
tags: ${{ steps.meta.outputs.tags }}
159-
labels: ${{ steps.meta.outputs.labels }}
160-
cache-from: type=gha
161-
cache-to: type=gha,mode=max
143+
node-version: '20'
144+
cache: 'yarn'
145+
146+
- name: Install dependencies
147+
run: yarn install --frozen-lockfile
148+
149+
- name: Build and push image
150+
env:
151+
COMMIT_SHA: ${{ github.sha }}
152+
run: |
153+
SHORT_SHA=$(echo $COMMIT_SHA | cut -c1-7)
154+
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
155+
REGISTRY="${{ steps.login-ecr.outputs.registry }}"
156+
157+
# Build the image
158+
yarn nx container ${{ matrix.service }} \
159+
--tags ${REGISTRY}/${{ env.ECR_REGISTRY_PREFIX }}-${{ matrix.service }}:${SHORT_SHA} \
160+
--tags ${REGISTRY}/${{ env.ECR_REGISTRY_PREFIX }}-${{ matrix.service }}:latest \
161+
--tags ${REGISTRY}/${{ env.ECR_REGISTRY_PREFIX }}-${{ matrix.service }}:${TIMESTAMP} \
162+
--push=${{ github.event_name != 'pull_request' }}
162163
163164
- name: Scan image for vulnerabilities
164165
if: github.event_name != 'pull_request'
166+
env:
167+
COMMIT_SHA: ${{ github.sha }}
165168
run: |
166-
# Extract commit SHA for image tag
167-
COMMIT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
169+
SHORT_SHA=$(echo $COMMIT_SHA | cut -c1-7)
168170
169171
# Wait for scan to complete
170172
aws ecr wait image-scan-complete \
171173
--repository-name ${{ env.ECR_REGISTRY_PREFIX }}-${{ matrix.service }} \
172-
--image-id imageTag=${COMMIT_SHA} \
174+
--image-id imageTag=${SHORT_SHA} \
173175
--region ${{ env.AWS_REGION }} || true
174176
175177
# Get scan findings
176178
SCAN_FINDINGS=$(aws ecr describe-image-scan-findings \
177179
--repository-name ${{ env.ECR_REGISTRY_PREFIX }}-${{ matrix.service }} \
178-
--image-id imageTag=${COMMIT_SHA} \
180+
--image-id imageTag=${SHORT_SHA} \
179181
--region ${{ env.AWS_REGION }} \
180182
--query 'imageScanFindings.findingSeverityCounts' \
181183
--output json || echo '{}')

0 commit comments

Comments
 (0)