-
Notifications
You must be signed in to change notification settings - Fork 1
46 lines (37 loc) · 1.36 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
name: Deploy to Production
on:
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy to Digital Ocean droplet via SSH action
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
passphrase: ${{ secrets.SSH_PASSPHRASE }}
command_timeout: 60m
script: |
ls
cd /home/treeckle/Treeckle-3.0
# Temp store changes
git stash
# Pull from git repo
git checkout master || true # Force return true so exit code is not 1
git pull
# Clear space
echo "${{ secrets.SUDO_PASSWORD }}" | sudo -S docker image prune -f
# Build frontend
cd frontend
echo "${{ secrets.SUDO_PASSWORD }}" | sudo -S bash ./build-prod.sh
cd ..
# Build backend
cd backend
echo "${{ secrets.SUDO_PASSWORD }}" | sudo -S docker build -t jermytan/treeckle-backend:production .
cd ..
# Deploy
echo "${{ secrets.SUDO_PASSWORD }}" | sudo -S docker-compose -f ./docker-compose.prod.yml up -d
# Restore changes
git stash pop || true # Force return true in case no changes stashed