-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (50 loc) · 1.86 KB
/
workflow.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: CICD Frontend and Backend
on:
push:
branches:
- main
jobs:
build-frontend:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build Docker frontend image
run: docker build -t luxshan/aws-pipeline-frontend ./frontend
- name: Publish frontend image to Docker Hub
run: docker push luxshan/aws-pipeline-frontend
build-backend:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build Docker backend image
run: docker build -t luxshan/aws-pipeline-backend ./backend
- name: Publish backend image to Docker Hub
run: docker push luxshan/aws-pipeline-backend
deploy:
needs: [build-frontend, build-backend]
runs-on: aws-ec2
steps:
- name: Pull frontend image from Docker Hub
run: docker pull luxshan/aws-pipeline-frontend
- name: Pull backend image from Docker Hub
run: docker pull luxshan/aws-pipeline-backend
- name: Delete old frontend container
run: docker rm -f aws-pipeline-frontend-container
- name: Delete old backend container
run: docker rm -f aws-pipeline-backend-container
- name: Run frontend container
run: docker run -d -p 3000:3000 --name aws-pipeline-frontend-container luxshan/aws-pipeline-frontend
- name: Run backend container
run: docker run -d -p 5000:5000 --name aws-pipeline-backend-container luxshan/aws-pipeline-backend