deploy-dokploy.yml63 lines · main
| 1 | name: Deploy to Dokploy |
| 2 | |
| 3 | # Auto-deploy on push to main (re-enabled 2026-07-19 by flndrn request). |
| 4 | # Also runnable by hand via workflow_dispatch. |
| 5 | # |
| 6 | # Secrets required: DOKPLOY_WEBHOOK_URL + DOKPLOY_API_KEY |
| 7 | # Dokploy compose autoDeploy should also be true so git webhooks / Actions both work. |
| 8 | |
| 9 | on: |
| 10 | push: |
| 11 | branches: [main] |
| 12 | workflow_dispatch: |
| 13 | inputs: |
| 14 | reason: |
| 15 | description: 'Why deploy? (note only)' |
| 16 | required: false |
| 17 | default: 'manual deploy' |
| 18 | |
| 19 | jobs: |
| 20 | deploy: |
| 21 | name: Deploy to dokploy |
| 22 | runs-on: ubuntu-latest |
| 23 | steps: |
| 24 | - name: Trigger Dokploy deploy |
| 25 | env: |
| 26 | DOKPLOY_WEBHOOK_URL: ${{ secrets.DOKPLOY_WEBHOOK_URL }} |
| 27 | DOKPLOY_API_KEY: ${{ secrets.DOKPLOY_API_KEY }} |
| 28 | GIT_REF: refs/heads/main |
| 29 | REPO_FULL: ${{ github.repository }} |
| 30 | REPO_NAME: ${{ github.event.repository.name }} |
| 31 | OWNER: ${{ github.repository_owner }} |
| 32 | SHA: ${{ github.sha }} |
| 33 | REASON: ${{ github.event.inputs.reason || github.event.head_commit.message || 'push' }} |
| 34 | run: | |
| 35 | set -euo pipefail |
| 36 | echo "Deploy trigger. Reason: ${REASON:-none}" |
| 37 | if [ -z "${DOKPLOY_WEBHOOK_URL:-}" ] || [ -z "${DOKPLOY_API_KEY:-}" ]; then |
| 38 | echo "::error::Missing DOKPLOY_WEBHOOK_URL or DOKPLOY_API_KEY secrets." |
| 39 | exit 1 |
| 40 | fi |
| 41 | payload=$(printf '%s' "{ |
| 42 | \"ref\": \"${GIT_REF}\", |
| 43 | \"after\": \"${SHA}\", |
| 44 | \"repository\": { |
| 45 | \"name\": \"${REPO_NAME}\", |
| 46 | \"full_name\": \"${REPO_FULL}\", |
| 47 | \"default_branch\": \"main\", |
| 48 | \"clone_url\": \"https://github.com/${REPO_FULL}.git\", |
| 49 | \"owner\": { \"login\": \"${OWNER}\", \"name\": \"${OWNER}\" } |
| 50 | } |
| 51 | }") |
| 52 | http_code=$(curl -sS -o /tmp/dokploy-response.txt -w "%{http_code}" \ |
| 53 | -X POST "${DOKPLOY_WEBHOOK_URL}" \ |
| 54 | -H "Authorization: Bearer ${DOKPLOY_API_KEY}" \ |
| 55 | -H "Content-Type: application/json" \ |
| 56 | -H "X-GitHub-Event: push" \ |
| 57 | -d "${payload}") |
| 58 | echo "Dokploy HTTP status: ${http_code}" |
| 59 | cat /tmp/dokploy-response.txt || true |
| 60 | case "${http_code}" in |
| 61 | 200|201|202|204) echo "Deploy trigger accepted." ;; |
| 62 | *) echo "::error::Dokploy rejected deploy"; exit 1 ;; |
| 63 | esac |