File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,16 +12,15 @@ jobs:
1212 github.event.workflow_run.conclusion == 'success'
1313 && startsWith(github.event.workflow_run.head_branch, '20')
1414 steps :
15- - name : Trigger deploy webhook
15+ - name : Deploy ${{ github.event.workflow_run.head_branch }}
1616 env :
1717 WEBHOOK_SECRET : ${{ secrets.DEPLOY_WEBHOOK_SECRET }}
18+ TAG : ${{ github.event.workflow_run.head_branch }}
1819 run : |
19- TAG="${{ github.event.workflow_run.head_branch }}"
20- REF="refs/tags/$TAG"
21- PAYLOAD="{\"ref\":\"$REF\"}"
20+ PAYLOAD="{\"ref\":\"refs/tags/$TAG\"}"
2221 SIGNATURE="sha256=$(echo -n "$PAYLOAD" | openssl dgst -sha256 -hmac "$WEBHOOK_SECRET" | cut -d' ' -f2)"
2322
24- HTTP_CODE=$(curl --max-time 120 \
23+ HTTP_CODE=$(curl -s - -max-time 120 \
2524 -o /tmp/deploy-output.txt \
2625 -w "%{http_code}" \
2726 -X POST \
3029 -d "$PAYLOAD" \
3130 "https://dochub.be/webhook/dochub-deploy")
3231
33- echo "=== Deploy output ==="
3432 cat /tmp/deploy-output.txt
3533
3634 if [ "$HTTP_CODE" != "200" ]; then
3735 echo "Webhook returned HTTP $HTTP_CODE"
3836 exit 1
3937 fi
40-
41- if ! grep -q "Deployed $TAG" /tmp/deploy-output.txt; then
42- echo "Deploy did not complete successfully"
43- exit 1
44- fi
Original file line number Diff line number Diff line change @@ -14,9 +14,23 @@ exec 200>/tmp/dochub-deploy.lock
1414flock -n 200 || { echo " Deploy already running, skipping" >&2 ; exit 1; }
1515
1616cd /srv/dochub/source
17+
18+ PREV=$( git describe --tags HEAD 2> /dev/null || git rev-parse --short HEAD)
19+ echo " Deploying $PREV -> $TAG "
20+ echo
21+
22+ echo " [1/4] Fetching and checking out $TAG ..."
1723git fetch --tags --prune origin
1824git checkout " $TAG "
25+
26+ echo " [2/4] Running migrations..."
1927/srv/dochub/.local/bin/uv run manage.py migrate --noinput
28+
29+ echo " [3/4] Collecting static files..."
2030/srv/dochub/.local/bin/uv run manage.py collectstatic --noinput
31+
32+ echo " [4/4] Restarting services..."
2133sudo /bin/systemctl restart dochub-gunicorn dochub-celery
22- echo " Deployed $TAG "
34+
35+ echo
36+ echo " Done. Deployed $TAG ."
You can’t perform that action at this time.
0 commit comments