Skip to content

Deploy sample platform #22

Deploy sample platform

Deploy sample platform #22

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