-
Notifications
You must be signed in to change notification settings - Fork 0
46 lines (44 loc) · 1.84 KB
/
main.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
name: Deploy 🚀
on:
push:
branches: [main]
workflow_dispatch:
jobs:
deploy:
name: Do it 💪
runs-on: ubuntu-latest
steps:
- name: Checkout latest code 🚚
uses: actions/checkout@v3
- name: Restore cache 📀
uses: actions/cache@v3
with:
path: |
~/.npm
${{ github.workspace }}/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
- name: Install dependencies ⏳
run: npm ci
- name: Build website 👷♀️
run: npm run build
- name: Copy prisma folder 💾
run: cp -R prisma/ .next/standalone/prisma/
- name: Copy public folder 🚝
run: cp -R public/ .next/standalone/public/
- name: Copy static folder 🗂
run: cp -R .next/static/ .next/standalone/.next/static/
- name: Install SSH Key 🔑
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: "just-a-placeholder-so-we-dont-get-errors"
- name: Adding Known Hosts 💾
run: ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts
- name: Deploy with rsync 💨
run: rsync -avz --delete .next/standalone/ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/var/www/issue.robvermeer.nl/ --exclude=.env.local --exclude=database/
- name: Migrate database 🪤
run: ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "cd /var/www/issue.robvermeer.nl/ && dotenv -e .env.local prisma migrate deploy"
- name: Restart server 🏁
run: ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "cd /var/www/issue.robvermeer.nl/ && pm2 reload issue"