-
Notifications
You must be signed in to change notification settings - Fork 2
109 lines (100 loc) · 3.57 KB
/
deploy-server.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
name: Deploy Server
on:
push:
branches:
- master
paths:
- backend/**
- deployment/**
- frontend/**
- email-templates-generator/**
- .github/workflows/deploy-server.yml
jobs:
changes:
name: Check changes on Front end
runs-on: ubuntu-latest
outputs:
backend: ${{ steps.filter.outputs.backend}}
frontend: ${{ steps.filter.outputs.frontend }}
email-templates: ${{ steps.filter.outputs.email-templates }}
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
base: ${{ github.ref }}
filters: |
backend:
- 'backend/**'
frontend:
- 'frontend/**'
email-templates:
- 'email-templates-generator/**'
frontend-quality:
name: Test front end quality
needs: changes
if: ${{ needs.changes.outputs.frontend == 'true' }}
uses: ./.github/workflows/quality-frontend.yml
secrets: inherit
backend-quality:
name: Test Back End Quality
needs: changes
if: ${{ needs.changes.outputs.backend == 'true' }}
uses: ./.github/workflows/quality-backend.yml
secrets: inherit
email-templates-quality:
name: Test Email Templates Quality
needs: changes
if: ${{ needs.changes.outputs.email-templates == 'true' }}
uses: ./.github/workflows/quality-email-templates.yml
secrets: inherit
frontend-build:
name: Build front end
needs: frontend-quality
uses: ./.github/workflows/build-frontend.yml
with:
target-directory: "nantralPlatform"
secrets: inherit
email-templates-build:
name: Build email templates
needs: email-templates-quality
uses: ./.github/workflows/build-email-templates.yml
with:
target-directory: "nantralPlatform"
secrets: inherit
backup-database:
name: Create a backup of the database
runs-on: ubuntu-latest
steps:
- name: Backup before deploy
uses: appleboy/[email protected]
with:
host: ${{ secrets.INSTANCE_ADDRESS }}
username: "ubuntu"
key: ${{ secrets.SSH_KEY_DEPLOY }}
script: |
set -e
cd nantralPlatform/deployment/scripts
chmod +x db_backup.sh
./db_backup.sh --skip-success-notif
deploy:
name: Deploy on VPS
needs:
[frontend-build, email-templates-build, backend-quality, backup-database]
if: ${{ always() && (needs.frontend-build.result == 'success' || needs.frontend-build.result == 'skipped') && (needs.email-templates-build.result == 'success' || needs.email-templates-build.result == 'skipped') && (needs.backend-quality.result == 'success' || needs.backend-quality.result == 'skipped') && (needs.backup-database.result == 'success') }}
runs-on: ubuntu-latest
steps:
- name: Deploy to the VPS
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.INSTANCE_ADDRESS }}
username: "ubuntu"
key: ${{ secrets.SSH_KEY_DEPLOY }}
script: |
set -e
cd nantralPlatform/deployment
git pull
sudo cp /etc/letsencrypt/live/nantral-platform.fr/privkey.pem /home/ubuntu/nantralPlatform/deployment/certs/key.pem
sudo cp /etc/letsencrypt/live/nantral-platform.fr/fullchain.pem /home/ubuntu/nantralPlatform/deployment/certs/cert.pem
sudo docker-compose -f docker-compose.yml -f docker-compose.prod.yml build --no-cache nginx backend celery celery-beat
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d