Deploy #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy | |
| on: | |
| push: | |
| tags: | |
| - 'v*.*.*' | |
| workflow_dispatch: | |
| inputs: | |
| ref: | |
| description: 'Git ref to deploy (tag, branch, or SHA). Defaults to origin/main.' | |
| required: false | |
| default: 'origin/main' | |
| concurrency: | |
| group: deploy-prod | |
| cancel-in-progress: false | |
| jobs: | |
| deploy: | |
| name: SSH deploy to Hetzner | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Deploy via SSH | |
| uses: appleboy/ssh-action@v1.2.0 | |
| with: | |
| host: ${{ secrets.HETZNER_HOST }} | |
| username: ${{ secrets.HETZNER_USER }} | |
| key: ${{ secrets.HETZNER_SSH_KEY }} | |
| port: 22 | |
| command_timeout: 15m | |
| script: | | |
| set -euo pipefail | |
| cd /opt/openstudy | |
| REF="${{ github.event.inputs.ref || github.ref_name }}" | |
| echo "Deploying ref: $REF" | |
| git fetch --all --tags | |
| git reset --hard "$REF" | |
| echo "Now at: $(git log -1 --oneline)" | |
| ./deploy.sh |