-
Notifications
You must be signed in to change notification settings - Fork 1
96 lines (81 loc) · 2.5 KB
/
ci.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
name: CI/CD
on: push
# Those variables required for the build to pass
# But they're not used when deployed as the build is run on the server
env:
CMS_URL: https://cms.tchoukball.ch
ST_CONTACT_EMAIL_RECIPIENT: [email protected]
jobs:
CI:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎
uses: actions/checkout@master
- name: Setup node env 🏗
uses: actions/[email protected]
with:
node-version: 20
check-latest: true
- name: Cache node_modules 📦
uses: actions/[email protected]
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies 👨🏻💻
run: npm ci --prefer-offline --no-audit
- name: Run linter 👀
run: npm run lint
- name: Build 🔨
run: npm run build
Deploy-to-staging:
if: ${{ github.ref == 'refs/heads/main' }}
needs: CI
runs-on: ubuntu-latest
environment:
name: Staging
url: https://next.tchoukball.ch
steps:
- name: Deploy to staging 🚀
uses: appleboy/[email protected]
with:
host: ${{secrets.SSH_HOST}}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
passphrase: ${{ secrets.SSH_PASSPHRASE }}
script: |
cd ~/sites/next.tchoukball.ch
git pull
source ~/.nvm/.profile
source ~/env_vars/website-staging.sh
nvm install
npm ci
npm run build
npm list -g pm2 || npm install -g pm2
pm2 restart website-nuxt-staging
Deploy-to-production:
if: ${{ github.ref == 'refs/heads/main' }}
needs: CI
runs-on: ubuntu-latest
environment:
name: Production
url: https://tchoukball.ch
steps:
- name: Deploy to production 🚀
uses: appleboy/[email protected]
with:
host: ${{secrets.SSH_HOST}}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
passphrase: ${{ secrets.SSH_PASSPHRASE }}
script: |
cd ~/sites/tchoukball.ch
git pull
source ~/.nvm/.profile
source ~/env_vars/website-prod.sh
nvm install
npm ci
npm run build
npm list -g pm2 || npm install -g pm2
pm2 restart website-nuxt-prod