-
Notifications
You must be signed in to change notification settings - Fork 1
55 lines (48 loc) · 1.55 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
name: BuildDeploy
on:
push:
branches:
- deployment
jobs:
build:
runs-on: ubuntu-latest
name: Build and Deploy
steps:
- name: Set env vars (common)
run: |
echo "REMOTE_HOST="${{ secrets.SSH_HOST }} >> $GITHUB_ENV
echo "REMOTE_APP_FOLDER=/var/www/html/Frontend-web-" >> $GITHUB_ENV
- name: Compress Files
run: |
touch build.tar.gz
tar --exclude=build.tar.gz -zcvf build.tar.gz ./.
- name: Copy build to server
uses: nogsantos/scp-deploy@master
with:
src: ./build.tar.gz
host: ${{ env.REMOTE_HOST }}
remote: ${{ env.REMOTE_APP_FOLDER }}
port: ${{ secrets.SSH_PORT }}
user: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
- name: SSH Decompress
uses: appleboy/ssh-action@master
with:
host: ${{ env.REMOTE_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.SSH_PORT }}
script: |
cd ${{ env.REMOTE_APP_FOLDER }}
tar xvzf ./build.tar.gz --directory ./
rm ./build.tar.gz
- name: SSH Start/Restart Application
uses: appleboy/ssh-action@master
with:
host: ${{ env.REMOTE_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.SSH_PORT }}
script: |
cd ${{ env.REMOTE_APP_FOLDER }}
sudo systemctl reload nginx