-
Notifications
You must be signed in to change notification settings - Fork 1
66 lines (60 loc) · 2.28 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
55
56
57
58
59
60
61
62
63
64
65
66
name: Deploy
on:
pull_request:
branches:
- develop
jobs:
deploy:
runs-on: ubuntu-latest
# if: github.event_name == 'pull_request' && github.event.pull_request.merged == true
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "18"
- name: Determine Deployment Type
if: ${{ success() }}
run: |
echo "DEPLOY_ASSETS=${{ contains(toJson(github.event.pull_request.labels.*.name), 'deploy:assets') }}" >> $GITHUB_ENV
echo "DEPLOY_SERVER=${{ contains(toJson(github.event.pull_request.labels.*.name), 'deploy:server') }}" >> $GITHUB_ENV
echo "DEPLOY_CLIENT=${{ contains(toJson(github.event.pull_request.labels.*.name), 'deploy:client') }}" >> $GITHUB_ENV
- name: Deploy
uses: appleboy/ssh-action@master
env:
DEPLOY_ASSETS: "${{ env.DEPLOY_ASSETS }}"
DEPLOY_SERVER: "${{ env.DEPLOY_SERVER }}"
DEPLOY_CLIENT: "${{ env.DEPLOY_CLIENT }}"
PUBLIC: "~/motsflex-save/public"
ASSETS: "$PUBLIC/assets"
INDEX_HTML: "$PUBLIC/index.html"
DICOS: "~/dicos"
SERVER: "~/motsflex-save/server.js"
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: 22
envs: DEPLOY_ASSETS,DEPLOY_SERVER,DEPLOY_CLIENT,PUBLIC,ASSETS,INDEX_HTML,DICOS,SERVER
script: |
cd /tmp/mots-fleches
git pull origin develop
npm install
npm run build
if [ "$DEPLOY_ASSETS" = 'true' ]; then
echo "Deploying JS assets"
rm -rf $ASSETS && mkdir -p $ASSETS"
cp -r dist/public/assets $ASSETS
cp -r dist/public/index.html $INDEX_HTML
fi
if [ "$DEPLOY_CLIENT" = 'true' ]; then
echo "Deploying full client"
rm -rf $PUBLIC && mkdir -p $PUBLIC
cp -r dist/public $PUBLIC
cp $DICOS/*.zip $ASSETS
fi
if [ "$DEPLOY_SERVER" = 'true' ]; then
echo "Deploying server code"
cp -r dist/server.js $SERVER
fi