-
Notifications
You must be signed in to change notification settings - Fork 48
63 lines (52 loc) · 1.96 KB
/
sp-deployment-pipeline.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
name: Deploy sample platform
on:
workflow_dispatch:
workflow_run:
workflows: [ "Run tests and code checks" ]
types: [ completed ]
branches:
- "master"
env:
DEPLOY_BRANCH: master
jobs:
deploy:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
permissions:
id-token: write
contents: read # required for actions/checkout
steps:
- name: Deployment with ssh commands using ssh key
uses: appleboy/ssh-action@master
with:
host: ${{ vars.PLATFORM_DOMAIN }}
username: ${{ vars.SSH_USER }}
key: ${{ secrets.SSH_KEY_PRIVATE }}
port: 22
script_stop: true
command_timeout: 10m
script: |
echo "defining directories"
INSTALL_FOLDER="/var/www/sample-platform"
SAMPLE_REPOSITORY="/repository"
echo "jump to app folder"
cd $INSTALL_FOLDER
echo "checkout branch"
sudo git restore .
sudo git checkout ${{env.DEPLOY_BRANCH}}
sudo git fetch origin ${{env.DEPLOY_BRANCH}}
echo "avoid merge conflicts"
sudo git reset --hard origin/${{env.DEPLOY_BRANCH}}
sudo git clean -f -d
echo "update app from git"
sudo git pull origin ${{env.DEPLOY_BRANCH}}
echo "update dependencies"
sudo python -m pip install -r requirements.txt
echo "run migrations"
sudo FLASK_APP=./run.py flask db upgrade
echo "update runCI script files"
sudo cp "install/ci-vm/ci-linux/ci/bootstrap" "${SAMPLE_REPOSITORY}/TestData/ci-linux/bootstrap"
sudo cp "install/ci-vm/ci-linux/ci/runCI" "${SAMPLE_REPOSITORY}/TestData/ci-linux/runCI"
sudo cp "install/ci-vm/ci-windows/ci/runCI.bat" "${SAMPLE_REPOSITORY}/TestData/ci-windows/runCI.bat"
echo "reload server"
sudo systemctl reload platform