name: Deploy on: push: branches: - main workflow_dispatch: inputs: branch: description: Git branch to deploy required: true default: main concurrency: group: production-deploy cancel-in-progress: false jobs: deploy: runs-on: ubuntu-latest steps: - name: Prepare SSH key and known_hosts env: DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }} DEPLOY_KNOWN_HOSTS: ${{ secrets.DEPLOY_KNOWN_HOSTS }} run: | install -m 700 -d ~/.ssh printf '%s\n' "$DEPLOY_SSH_KEY" > ~/.ssh/id_ed25519 printf '%s\n' "$DEPLOY_KNOWN_HOSTS" > ~/.ssh/known_hosts chmod 600 ~/.ssh/id_ed25519 ~/.ssh/known_hosts - name: Run deployment on server env: DEPLOY_BRANCH: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.branch || github.ref_name }} DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }} DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }} DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }} DEPLOY_USER: ${{ secrets.DEPLOY_USER }} run: | ssh -i ~/.ssh/id_ed25519 -p "${DEPLOY_PORT:-22}" "${DEPLOY_USER}@${DEPLOY_HOST}" \ "cd \"${DEPLOY_PATH}\" && bash scripts/update-from-github.sh \"${DEPLOY_BRANCH}\""