-
Notifications
You must be signed in to change notification settings - Fork 10
44 lines (41 loc) · 1.23 KB
/
deploy.yml
File metadata and controls
44 lines (41 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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 }}"
# Normalize bare branch names to origin/<branch> so the reset
# picks up the freshly-fetched commits, not the stale local branch.
if [[ "$REF" != origin/* && "$REF" != v* ]]; then
REF="origin/$REF"
fi
echo "Deploying ref: $REF"
git fetch --all --tags
git reset --hard "$REF"
echo "Now at: $(git log -1 --oneline)"
./deploy.sh