-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (100 loc) · 3.42 KB
/
TFG.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
107
108
109
110
111
112
113
name: CI for TFG
on:
push:
branches:
- develop
pull_request:
branches:
- develop
release:
types: [published]
jobs:
docker-push-webapp:
name: Push webapp Docker Image to GitHub Packages
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Node.js 20
uses: actions/setup-node@v3
with:
node-version: 20
- name: Log in to GitHub Docker registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: ./webapp
push: true
tags: ghcr.io/${{ github.repository_owner }}/webapp:latest
build-args: |
API_URI=${{ secrets.API_URI }}
docker-push-restapi:
name: Push restapi Docker Image to GitHub Packages
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Node.js 20
uses: actions/setup-node@v3
with:
node-version: 20
- name: Log in to GitHub Docker registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: ./restapi
push: true
tags: ghcr.io/${{ github.repository_owner }}/restapi:latest
build-args: |
MONGO_URI=${{ secrets.MONGO_URI }}
TOKEN_SECRET=${{ secrets.TOKEN_SECRET }}
PAYPAL_CLIENT_ID=${{ secrets.PAYPAL_CLIENT_ID }}
PAYPAL_CLIENT_SECRET=${{ secrets.PAYPAL_CLIENT_SECRET }}
PAYPAL_TOKEN=${{ secrets.PAYPAL_TOKEN }}
SSL_CERT=${{ secrets.SSL_CERT }}
SSL_PRIVKEY=${{ secrets.SSL_PRIVKEY }}
NODE_ENV=production
deploy:
name: Deploy over SSH
runs-on: ubuntu-latest
needs: [docker-push-restapi,docker-push-webapp]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Create docker-compose.yml
run: echo "${{ secrets.DOCKER_COMPOSE_DEPLOY }}" > docker-compose.yml
- name: Docker Login on Remote
uses: fifsky/ssh-action@master
with:
host: ${{ secrets.DEPLOY_HOST }}
user: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_KEY }}
command: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Deploy over SSH
uses: fifsky/ssh-action@master
with:
host: ${{ secrets.DEPLOY_HOST }}
user: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_KEY }}
command: |
export MONGO_URI=${{ secrets.MONGO_URI }}
export TOKEN_SECRET=${{ secrets.TOKEN_SECRET }}
export PAYPAL_CLIENT_ID=${{ secrets.PAYPAL_CLIENT_ID }}
export PAYPAL_CLIENT_SECRET=${{ secrets.PAYPAL_CLIENT_SECRET }}
export PAYPAL_TOKEN=${{ secrets.PAYPAL_TOKEN }}
export SSL_CERT=${{ secrets.SSL_CERT }}
export SSL_PRIVKEY=${{ secrets.SSL_PRIVKEY }}
sudo docker-compose stop
sudo docker-compose rm -f
sudo docker-compose pull
sudo docker-compose up -d