-
Notifications
You must be signed in to change notification settings - Fork 1
58 lines (49 loc) · 1.98 KB
/
continuous-deployment.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
name: Continuous Deployment
on:
push:
branches:
- main
jobs:
build_and_deployment:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: npm install
- name: Create tarball of the repository
run: |
mkdir -p archive
tar --exclude='./archive' --exclude='./node_modules' --exclude='./.git' -czf archive/i-mader-landing-page.tar.gz .
- name: Adding private SSH key to ssh-agent
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
mkdir -p ~/.ssh
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
ssh-keyscan github.com >> ~/.ssh/known_hosts
ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}"
- name: scp binary to GCE and apply latest version
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "
rm -rf /root/i-mader-landing-page/*
echo '** old files removed **'
"
scp -o StrictHostKeyChecking=no -r archive/i-mader-landing-page.tar.gz ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/root/i-mader-landing-page
ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "
cd i-mader-landing-page && tar -xzf i-mader-landing-page.tar.gz
echo '** files extracted **'
rm i-mader-lending-page.tar.gz
echo "** restarting service tof apply new version **"
ls -la /root/i-mader-landing-page # Debugging step to list contents of out directory
npm install
npm run build
pm2 stop i-mader.tech
pm2 start npm --name "i-mader.tech" -- start
# Save the PM2 process list
pm2 save
# Set up PM2 to start on system boot
pm2 startup systemd
echo "** service started **"
" || exit 1