Skip to content

Commit c3fe44a

Browse files
[FEATURE] Implement CI/CD for sample-platform (#811)
Co-authored-by: Shivam Kumar Jha <code@thealphadollar.me>
1 parent 5ea5edf commit c3fe44a

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Deploy sample platform
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ master ]
7+
8+
env:
9+
DEPLOY_BRANCH: master
10+
11+
jobs:
12+
deploy:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
id-token: write
16+
contents: read # required for actions/checkout
17+
steps:
18+
- name: Deployment with ssh commands using ssh key
19+
uses: appleboy/ssh-action@master
20+
with:
21+
host: ${{ vars.PLATFORM_DOMAIN }}
22+
username: ${{ vars.SSH_USER }}
23+
key: ${{ secrets.SSH_KEY_PRIVATE }}
24+
port: 22
25+
script_stop: true
26+
command_timeout: 10m
27+
script: |
28+
echo "jump to app folder"
29+
cd /var/www/sample-platform
30+
31+
echo "checkout branch"
32+
sudo git restore .
33+
sudo git checkout ${{env.DEPLOY_BRANCH}}
34+
sudo git fetch origin ${{env.DEPLOY_BRANCH}}
35+
36+
echo "avoid merge conflicts"
37+
sudo git reset --hard origin/${{env.DEPLOY_BRANCH}}
38+
sudo git clean -f -d
39+
40+
echo "update app from git"
41+
sudo git pull origin ${{env.DEPLOY_BRANCH}}
42+
43+
echo "update dependencies"
44+
sudo python -m pip install -r requirements.txt
45+
46+
echo "run migrations"
47+
sudo FLASK_APP=./run.py flask db upgrade
48+
49+
echo "reload server"
50+
sudo systemctl reload platform

0 commit comments

Comments
 (0)