Skip to content

Commit 9a66480

Browse files
committed
Add CI/CD pipeline to build & push Docker images
1 parent aa9f060 commit 9a66480

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

.github/workflows/ci-cd.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Build and Push Docker Images
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v3
15+
16+
# LOGIN TO GHCR
17+
- name: Log in to GHCR
18+
run: echo "${{ secrets.GHCR_TOKEN }}" | docker login ghcr.io -u "${{ secrets.GHCR_USERNAME }}" --password-stdin
19+
20+
# BUILD FRONTEND IMAGE
21+
- name: Build frontend image
22+
run: |
23+
docker build -t ghcr.io/${{ secrets.GHCR_USERNAME }}/devops-frontend:latest ./frontend
24+
25+
# BUILD BACKEND IMAGE
26+
- name: Build backend image
27+
run: |
28+
docker build -t ghcr.io/${{ secrets.GHCR_USERNAME }}/devops-backend:latest ./backend
29+
30+
# PUSH IMAGES
31+
- name: Push frontend
32+
run: docker push ghcr.io/${{ secrets.GHCR_USERNAME }}/devops-frontend:latest
33+
34+
- name: Push backend
35+
run: docker push ghcr.io/${{ secrets.GHCR_USERNAME }}/devops-backend:latest

0 commit comments

Comments
 (0)