-
-
Notifications
You must be signed in to change notification settings - Fork 30
101 lines (84 loc) · 3.56 KB
/
build.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
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Build
on:
push:
branches: ["master"]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
cache: 'npm'
node-version: 20
- uses: actions/cache@v3
with:
# See here for caching with `yarn` https://github.com/actions/cache/blob/main/examples.md#node---yarn or you can leverage caching with actions/setup-node https://github.com/actions/setup-node
path: |
~/.npm
${{ github.workspace }}/.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
- name: ssh tunnel to mysql database
run: |
mkdir -p ~/.ssh/
ssh-keyscan -H ara.uberspace.de >> ~/.ssh/known_hosts
eval `ssh-agent -s`
ssh-add - <<< "${{secrets.SSH_PRIVATE_KEY}}"
ssh -fN -L 3306:127.0.0.1:3306 [email protected]
ssh -fN -L 5432:127.0.0.1:5432 [email protected]
- name: Install
run: npm install
- run: printf "${{ secrets.ENV_LOCAL }}" >> .env.local
- name: Build
run: npm run build
- name: zip
run: zip -r build.zip .next
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: build-data
path: build.zip
deploy-beta:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: build-data
- name: ssh tunnel for upload
run: |
mkdir -p ~/.ssh/
ssh-keyscan -H ara.uberspace.de >> ~/.ssh/known_hosts
eval `ssh-agent -s`
ssh-add - <<< "${{secrets.SSH_PRIVATE_KEY}}"
ssh -fN -L 3306:127.0.0.1:3306 [email protected]
ssh -fN -L 5432:127.0.0.1:5432 [email protected]
- name: upload
run: |
ssh-keyscan -H ara.uberspace.de >> ~/.ssh/known_hosts
eval `ssh-agent -s`
ssh-add - <<< "${{secrets.SSH_PRIVATE_KEY}}"
scp build.zip [email protected]:~/html/HEAD/
- name: unzip
run: |
ssh-keyscan -H ara.uberspace.de >> ~/.ssh/known_hosts
eval `ssh-agent -s`
ssh-add - <<< "${{secrets.SSH_PRIVATE_KEY}}"
ssh [email protected] 'rm -rf ~/html/HEAD/.next'
ssh [email protected] 'unzip -d ~/html/HEAD/ ~/html/HEAD/build.zip'
- name: restart
run: |
ssh-keyscan -H ara.uberspace.de >> ~/.ssh/known_hosts
eval `ssh-agent -s`
ssh-add - <<< "${{secrets.SSH_PRIVATE_KEY}}"
ssh [email protected] 'supervisorctl stop beta'
ssh [email protected] '/home/duostori/html/kill_rouge_workers.py'
ssh [email protected] '/home/duostori/html/kill_port_users.py beta'
ssh [email protected] 'supervisorctl start beta'