-
Notifications
You must be signed in to change notification settings - Fork 2
58 lines (49 loc) · 1.38 KB
/
CD.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
58
# CD Backend
name: CD BE
on:
push:
branches:
- main
jobs:
build_dev_test:
name: Build Backend For Dev files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build Backend For Dev files
run: |
docker build -t dev-backend -f Dockerfile.dev .
- name: Run Backend For Testing Dev files
run: |
docker run --rm dev-backend
build_push_docker:
name: Build Backend For Prod files and push to docker
runs-on: ubuntu-latest
needs: build_dev_test
steps:
- uses: actions/checkout@v2
- name: Build Backend For Prod files
run: |
docker build -t aoudaa/dkr-backend:latest .
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push Docker Backend image
run: |
docker push aoudaa/dkr-backend:latest
deploy:
name: Deploy Backend For Prod files
runs-on: ubuntu-latest
needs: build_push_docker
steps:
- name: ssh into vm and run the script
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: |
cd ~/docker
sh deployBE.sh