-
Notifications
You must be signed in to change notification settings - Fork 5
96 lines (85 loc) · 3.97 KB
/
deploy-production.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
name: Deploy and Run Flyway Migrations production
on:
push:
branches:
- production
jobs:
deploy_and_migrate:
runs-on: ubuntu-22.04
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Deploy to server via rsync
uses: Burnett01/rsync-deployments@5.2
with:
switches: -avzr --checksum --delete --exclude-from='.gitignore' --exclude='/config/nginx/conf.d/custom.conf'
path: ./
remote_path: ${{ secrets.PROD_REMOTE_PATH }}
remote_host: ${{ secrets.PROD_HOST }}
remote_user: ${{ secrets.PROD_USER }}
remote_key: ${{ secrets.PROD_KEY }}
remote_key_pass: ${{ secrets.PROD_KEY_PASS }}
- name: Generate version and minify on server
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.PROD_HOST }}
username: ${{ secrets.PROD_USER }}
key: ${{ secrets.PROD_KEY }}
passphrase: ${{ secrets.PROD_KEY_PASS }}
script: |
TIMESTAMP=$(date +%Y%m%d%H%M)
echo "{\"version\":\"$TIMESTAMP\"}" > ${{ secrets.PROD_REMOTE_PATH }}/www/frontend/custom_theme/css/version.json
echo "{\"version\":\"$TIMESTAMP\"}" > ${{ secrets.PROD_REMOTE_PATH }}/www/frontend/custom_theme/js/version.json
docker run --rm \
-v ${{ secrets.PROD_REMOTE_PATH }}/www:/www \
node:18 sh -c "npm install -g csso-cli && \
csso /www/frontend/custom_theme/css/styles.css --output /www/frontend/custom_theme/css/styles.min.css"
docker run --rm \
-v ${{ secrets.PROD_REMOTE_PATH }}/www:/www \
node:18 sh -c "npm install -g terser && \
terser /www/frontend/custom_theme/js/scripts.js --compress --mangle --output /www/frontend/custom_theme/js/scripts.min.js"
- name: Run Flyway Migrations core
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.PROD_HOST }}
username: ${{ secrets.PROD_USER }}
key: ${{ secrets.PROD_KEY }}
passphrase: ${{ secrets.PROD_KEY_PASS }}
script: |
docker run --rm \
--network npm_network \
--volume ${{ secrets.PROD_REMOTE_PATH }}/config/db/core:/flyway/core:ro \
-e FLYWAY_URL="${{ secrets.PROD_DB_URL }}" \
-e FLYWAY_USER="${{ secrets.PROD_DB_USER }}" \
-e FLYWAY_PASSWORD="${{ secrets.PROD_DB_PASSWORD }}" \
flyway/flyway -locations=filesystem:/flyway/core -table=flyway_core migrate
- name: Run Flyway Migrations core
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.PROD_HOST }}
username: ${{ secrets.PROD_USER }}
key: ${{ secrets.PROD_KEY }}
passphrase: ${{ secrets.PROD_KEY_PASS }}
script: |
docker run --rm \
--network npm_network \
--volume ${{ secrets.PROD_REMOTE_PATH }}/config/db/core:/flyway/core:ro \
-e FLYWAY_URL="${{ secrets.PROD_DB_URL }}" \
-e FLYWAY_USER="${{ secrets.PROD_DB_USER }}" \
-e FLYWAY_PASSWORD="${{ secrets.PROD_DB_PASSWORD }}" \
flyway/flyway -locations=filesystem:/flyway/core -table=flyway_core migrate
- name: Run Flyway Migrations myapp
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.PROD_HOST }}
username: ${{ secrets.PROD_USER }}
key: ${{ secrets.PROD_KEY }}
passphrase: ${{ secrets.PROD_KEY_PASS }}
script: |
docker run --rm \
--network npm_network \
--volume ${{ secrets.PROD_REMOTE_PATH }}/config/db/myapp:/flyway/myapp:ro \
-e FLYWAY_URL="${{ secrets.PROD_DB_URL }}" \
-e FLYWAY_USER="${{ secrets.PROD_DB_USER }}" \
-e FLYWAY_PASSWORD="${{ secrets.PROD_DB_PASSWORD }}" \
flyway/flyway -locations=filesystem:/flyway/myapp -table=flyway_myapp migrate