Skip to content

CD

CD #2

Workflow file for this run

name: CD
on:
workflow_run:
workflows:
- CI
types:
- completed
branches:
- main
- master
workflow_dispatch:
concurrency:
group: sg-stats-server-prod
cancel-in-progress: true
jobs:
deploy:
name: Deploy to Production
if: ${{ github.event_name == 'workflow_dispatch' || (github.event.workflow_run.event == 'push' && github.event.workflow_run.conclusion == 'success') }}
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Deploy over SSH
uses: appleboy/ssh-action@v1.2.2
env:
APP_DIR: ${{ secrets.CD_APP_DIR }}
BRANCH: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_branch || github.ref_name }}
with:
host: ${{ secrets.CD_SSH_HOST }}
username: ${{ secrets.CD_SSH_USER }}
key: ${{ secrets.CD_SSH_PRIVATE_KEY }}
port: ${{ secrets.CD_SSH_PORT }}
script_stop: true
command_timeout: 30m
envs: APP_DIR,BRANCH
script: |
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
bash "$APP_DIR/deploy/remote-deploy.sh" "$APP_DIR" "$BRANCH"