-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (48 loc) · 1.6 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
55
56
57
name: CICD
on:
push:
branches:
- main
jobs:
build-frontend:
runs-on: self-hosted
steps:
- name: Checkout source
uses: actions/checkout@v2
- name: Build and push frontend Docker image
run: |
cd frontend
docker build -t luxshan/frontend:latest .
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker push luxshan/frontend:latest
build-backend:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v2
- name: Build and push backend Docker image
run: |
cd backend
docker build -t luxshan/backend:latest .
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker push luxshan/backend:latest
deploy:
needs: [build-frontend, build-backend]
runs-on: self-hosted
steps:
- name: Pull frontend and backend images from Docker Hub
run: |
docker pull luxshan/frontend:latest
docker pull luxshan/backend:latest
- name: Stop and remove old containers
run: |
docker stop frontend-container || true
docker rm frontend-container || true
docker stop backend-container || true
docker rm backend-container || true
- name: Run frontend container
run: |
docker run -d -p 3000:3000 --name frontend-container luxshan/frontend:latest
- name: Run backend container
run: |
docker run -d -p 5000:5000 --name backend-container luxshan/backend:latest