forked from matias-rivera/restobar
-
Notifications
You must be signed in to change notification settings - Fork 4
106 lines (95 loc) · 3.45 KB
/
base.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: build
on:
push:
branches:
- master
jobs:
create-docker-image-front:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2
- name: Login to GitHub Container Registry (with lowercase username)
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }} # Convert username to lowercase
password: ${{ secrets.GH_TOKEN }}
- name: Build and push comandera
uses: docker/build-push-action@v2
with:
context: .
file: ./front.Dockerfile
push: true
tags: ghcr.io/elimeleth/ft-comandera:latest # Use lowercase username in tag
continue-on-error: false
create-docker-image-backend:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2
- name: Login to GitHub Container Registry (with lowercase username)
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }} # Convert username to lowercase
password: ${{ secrets.GH_TOKEN }}
- name: Build and push comandera
uses: docker/build-push-action@v2
with:
context: .
file: ./api.Dockerfile
push: true
tags: ghcr.io/elimeleth/bc-comandera:latest # Use lowercase username in tag
continue-on-error: false
deploy-backend:
needs: create-docker-image-backend
runs-on: ubuntu-latest
steps:
- name: Install sshpass
run: sudo apt-get install -y sshpass
- name: SSH into Server (with lowercase username in Docker commands)
run: |
sshpass -p ${{secrets.AUTH_PASS}} ssh -o StrictHostKeyChecking=no ${{secrets.AUTH_SERVER}} << EOF
cd /home/comandera/
docker login ghcr.io -u elimeleth -p ${{secrets.GH_TOKEN}}
docker pull ghcr.io/elimeleth/bc-comandera:latest
docker rm -f bc-comandera 2>/dev/null
docker run -d \
--name bc-comandera \
--user 0:0 \
-p 5000:5000 \
--cap-add=SYS_ADMIN \
-e DB_USER=${{secrets.DB_USER}} \
-e DB_HOST=${{secrets.DB_HOST}} \
-e DB_NAME=${{secrets.DB_NAME}} \
-e DB_PASSWORD=${{secrets.DB_PASSWORD}} \
-e DB_DIALECT=${{secrets.DB_DIALECT}} \
-e DB_PORT=${{secrets.DB_PORT}} \
-e NODE_ENV=development \
-e PORT=5000 \
-e JWT_SECRET=abc123 \
--restart always \
ghcr.io/elimeleth/bc-comandera:latest
EOF
deploy-front:
needs: create-docker-image-front
runs-on: ubuntu-latest
steps:
- name: Install sshpass
run: sudo apt-get install -y sshpass
- name: SSH into Server (with lowercase username in Docker commands)
run: |
sshpass -p ${{secrets.AUTH_PASS}} ssh -o StrictHostKeyChecking=no ${{secrets.AUTH_SERVER}} << EOF
cd /home/comandera/
docker login ghcr.io -u elimeleth -p ${{secrets.GH_TOKEN}}
docker pull ghcr.io/elimeleth/ft-comandera:latest
docker rm -f ft-comandera 2>/dev/null
docker run -d \
--name ft-comandera \
--user 0:0 \
-p 3000:3000 \
--cap-add=SYS_ADMIN \
--restart always \
ghcr.io/elimeleth/ft-comandera:latest
EOF