58 lines
2.1 KiB
YAML
58 lines
2.1 KiB
YAML
name: Manual Deploy
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
branch:
|
|
description: Branch to deploy
|
|
required: true
|
|
default: main
|
|
target_dir:
|
|
description: Target directory on server
|
|
required: true
|
|
default: ~/egbim
|
|
db_dump_path:
|
|
description: SQL dump path inside repository
|
|
required: true
|
|
default: egbim_DB.sql
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup SSH key
|
|
shell: bash
|
|
run: |
|
|
install -m 700 -d ~/.ssh
|
|
printf '%s\n' '${{ secrets.DEPLOY_SSH_KEY }}' > ~/.ssh/id_ed25519
|
|
chmod 600 ~/.ssh/id_ed25519
|
|
ssh-keyscan -p '${{ secrets.DEPLOY_PORT }}' '${{ secrets.DEPLOY_HOST }}' >> ~/.ssh/known_hosts
|
|
|
|
- name: Render deployment env
|
|
shell: bash
|
|
run: |
|
|
cat > /tmp/egbim.deploy.env <<EOF
|
|
APP_ENV=${{ secrets.APP_ENV }}
|
|
APP_PORT=${{ secrets.APP_PORT }}
|
|
DB_PORT=${{ secrets.DB_PORT }}
|
|
G5_MYSQL_DB=${{ secrets.G5_MYSQL_DB }}
|
|
G5_MYSQL_USER=${{ secrets.G5_MYSQL_USER }}
|
|
G5_MYSQL_PASSWORD=${{ secrets.G5_MYSQL_PASSWORD }}
|
|
MARIADB_ROOT_PASSWORD=${{ secrets.MARIADB_ROOT_PASSWORD }}
|
|
COMPOSE_PROJECT_NAME=${{ secrets.COMPOSE_PROJECT_NAME }}
|
|
EOF
|
|
|
|
- name: Upload deployment script
|
|
shell: bash
|
|
run: |
|
|
scp -P '${{ secrets.DEPLOY_PORT }}' -i ~/.ssh/id_ed25519 scripts/deploy_remote.sh '${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }}:/tmp/egbim_deploy_remote.sh'
|
|
scp -P '${{ secrets.DEPLOY_PORT }}' -i ~/.ssh/id_ed25519 /tmp/egbim.deploy.env '${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }}:/tmp/egbim.deploy.env'
|
|
|
|
- name: Run deploy
|
|
shell: bash
|
|
run: |
|
|
ssh -p '${{ secrets.DEPLOY_PORT }}' -i ~/.ssh/id_ed25519 '${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }}' \
|
|
"chmod +x /tmp/egbim_deploy_remote.sh && /tmp/egbim_deploy_remote.sh '${{ inputs.branch }}' '${{ inputs.target_dir }}' /tmp/egbim.deploy.env '${{ inputs.db_dump_path }}'" |