-
-
Notifications
You must be signed in to change notification settings - Fork 43
54 lines (48 loc) · 1.5 KB
/
deploy.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
name: Build and Deploy to flok.cc
on:
push:
branches:
- main
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 20
- run: npm install
- run: npm run build
- name: Configure SSH
run: |
mkdir -p ~/.ssh/
echo "$SSH_KEY" > ~/.ssh/prod.key
chmod 600 ~/.ssh/prod.key
cat >>~/.ssh/config <<END
Host prod
HostName $SSH_HOST
User $SSH_USER
IdentityFile ~/.ssh/prod.key
StrictHostKeyChecking no
END
env:
SSH_USER: ${{ secrets.SSH_USER }}
SSH_KEY: ${{ secrets.SSH_KEY }}
SSH_HOST: ${{ secrets.SSH_HOST }}
- name: Update remote repository and install dependencies
run: ssh prod 'cd flok && git fetch && git reset --hard ${{ github.sha }} && npm install'
- name: Sync web build
uses: burnett01/rsync-deployments@7.0.0
with:
switches: -avzr --delete
path: packages/web/dist/
remote_path: flok/packages/web/dist/
remote_host: ${{ secrets.SSH_HOST }}
remote_user: ${{ secrets.SSH_USER }}
remote_key: ${{ secrets.SSH_KEY }}
- name: Restart server
run: ssh prod 'sudo systemctl restart flok && sleep 5 && sudo systemctl status flok'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true