-
Notifications
You must be signed in to change notification settings - Fork 1
54 lines (48 loc) · 1.53 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: Deploy
on:
push:
branches:
- master
- plausible
jobs:
deploy:
runs-on: ubuntu-latest
env:
TARGET: ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_HOST }}
KEY: /tmp/private-key
DIR: ~/motsflex
DICOS: ~/dicos
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Setup
run: |
mkdir -p ~/.ssh/ && touch ~/.ssh/known_hosts
ssh-keyscan ${{ secrets.SERVER_HOST }} >> ~/.ssh/known_hosts
echo "${{ secrets.SSH_PRIVATE_KEY }}" > $KEY
chmod 600 $KEY
echo "PUBLIC=$DIR/public" >> $GITHUB_ENV
echo "SERVER=${{ env.DIR }}/server.js" >> $GITHUB_ENV
echo "ASSETS=${{ env.DIR }}/public/assets" >> $GITHUB_ENV
echo "INDEX_HTML=${{ env.DIR }}/public/index.html" >> $GITHUB_ENV
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "18"
- name: Install Dependencies
if: ${{ success() }}
run: npm ci
- name: Build
if: ${{ success() }}
run: npm run build
- name: Deploy
if: ${{ success() }}
run: |
echo "Deploying full client"
ssh -i $KEY $TARGET "rm -rf $PUBLIC && mkdir -p $PUBLIC"
scp -i $KEY -r dist/public/* "$TARGET:$PUBLIC"
ssh -i $KEY $TARGET "cp $DICOS/*.zip $PUBLIC"
echo "Deploying server code"
scp -i $KEY -r dist/server.js "$TARGET:$SERVER"
- name: Cleanup
run: "rm -f $KEY && rm -rf ~/.ssh"