Skip to content

Commit a6d60c2

Browse files
author
colto
committed
Push images to ECR from CI
1 parent 2a5bc0d commit a6d60c2

3 files changed

Lines changed: 72 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
pull_request:
77
branches: ["main"]
88

9+
permissions:
10+
id-token: write
11+
contents: read
12+
913
jobs:
1014
backend-build:
1115
name: Backend Build (Spring Boot)
@@ -86,3 +90,65 @@ jobs:
8690
context: ./frontend
8791
push: false
8892
tags: cloudpulse-frontend:ci
93+
94+
backend-ecr-push:
95+
name: Push Backend Image to ECR
96+
runs-on: ubuntu-latest
97+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
98+
99+
steps:
100+
- name: Checkout repo
101+
uses: actions/checkout@v4
102+
103+
- name: Configure AWS credentials (OIDC)
104+
uses: aws-actions/configure-aws-credentials@v4
105+
with:
106+
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
107+
aws-region: ${{ secrets.AWS_REGION }}
108+
109+
- name: Login to Amazon ECR
110+
id: login-ecr
111+
uses: aws-actions/amazon-ecr-login@v2
112+
113+
- name: Set up Docker Buildx
114+
uses: docker/setup-buildx-action@v3
115+
116+
- name: Build and push backend
117+
uses: docker/build-push-action@v6
118+
with:
119+
context: ./backend
120+
push: true
121+
tags: |
122+
${{ steps.login-ecr.outputs.registry }}/cloudpulse-backend:${{ github.sha }}
123+
${{ steps.login-ecr.outputs.registry }}/cloudpulse-backend:latest
124+
125+
frontend-ecr-push:
126+
name: Push Frontend Image to ECR
127+
runs-on: ubuntu-latest
128+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
129+
130+
steps:
131+
- name: Checkout repo
132+
uses: actions/checkout@v4
133+
134+
- name: Configure AWS credentials (OIDC)
135+
uses: aws-actions/configure-aws-credentials@v4
136+
with:
137+
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
138+
aws-region: ${{ secrets.AWS_REGION }}
139+
140+
- name: Login to Amazon ECR
141+
id: login-ecr
142+
uses: aws-actions/amazon-ecr-login@v2
143+
144+
- name: Set up Docker Buildx
145+
uses: docker/setup-buildx-action@v3
146+
147+
- name: Build and push frontend
148+
uses: docker/build-push-action@v6
149+
with:
150+
context: ./frontend
151+
push: true
152+
tags: |
153+
${{ steps.login-ecr.outputs.registry }}/cloudpulse-frontend:${{ github.sha }}
154+
${{ steps.login-ecr.outputs.registry }}/cloudpulse-frontend:latest

documentation/progress-log.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,8 @@
3636

3737
- Added GitHub Actions CI workflow
3838
- Workflow builds backend (Maven) and frontend (Vite)
39-
- Verified CI runs successfully on push
39+
- Verified CI runs successfully on push
40+
41+
- Updated GitHub Actions CI to build backend Docker image
42+
- Updated GitHub Actions CI to build frontend Docker image
43+
- Verified Docker builds succeed in CI

documentation/roadmap.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@
2828

2929
## Phase 4 (CI/CD)
3030
- [x] GitHub Actions build/test
31+
- [x] CI builds Docker images
3132
- [ ] GitHub Actions deploy

0 commit comments

Comments
 (0)