Generic host/repo/branch-aware CD on adnanh/webhook
Replaces the per-project deploy scripts and self-contained webhook receivers with one manifest-driven implementation that lives outside the application repositories and can be updated independently of them. First targets: domaindingo test and prod on s5.
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
# ntfy CI Notification Setup
|
||||
|
||||
Send an `ntfy` message on workflow success and another on failure, for push
|
||||
events only. Needs `curl` in the runner and the ntfy server reachable from CI.
|
||||
|
||||
- Base URL via workflow env: `NTFY_BASE_URL: https://ntfy.fisher.hu`
|
||||
- Topic = repo name with `/` → `-`: `topic="${GITHUB_REPOSITORY//\//-}"`
|
||||
(e.g. `webdev/domaindingo` → `webdev-domaindingo`)
|
||||
|
||||
```yaml
|
||||
env:
|
||||
NTFY_BASE_URL: https://ntfy.fisher.hu
|
||||
|
||||
jobs:
|
||||
notify_ok:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build, publish_project_status] # replace with your pipeline jobs
|
||||
if: ${{ always() && github.event_name == 'push' && needs.build.result == 'success' && needs.publish_project_status.result == 'success' }}
|
||||
steps:
|
||||
- name: Notify ntfy (success)
|
||||
env: { COMMIT_MESSAGE: "${{ github.event.head_commit.message }}" }
|
||||
run: |
|
||||
topic="${GITHUB_REPOSITORY//\//-}"
|
||||
curl -fsS -d "✅ Repo: ${GITHUB_REPOSITORY} | Branch: ${GITHUB_REF_NAME} | Message: ${COMMIT_MESSAGE}" \
|
||||
"${NTFY_BASE_URL}/${topic}"
|
||||
|
||||
notify_failure:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build, publish_project_status]
|
||||
if: ${{ always() && github.event_name == 'push' && (needs.build.result != 'success' || needs.publish_project_status.result != 'success') }}
|
||||
steps:
|
||||
- name: Notify ntfy (failure)
|
||||
env: { COMMIT_MESSAGE: "${{ github.event.head_commit.message }}" }
|
||||
run: |
|
||||
topic="${GITHUB_REPOSITORY//\//-}"
|
||||
curl -fsS -d "❌ Repo: ${GITHUB_REPOSITORY} | Branch: ${GITHUB_REF_NAME} | Message: ${COMMIT_MESSAGE}" \
|
||||
"${NTFY_BASE_URL}/${topic}"
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- `needs:` must list the jobs that define "done"; the `if:` expressions decide
|
||||
success vs. failure. Keep `always()` so the failure job still runs when an
|
||||
upstream job fails.
|
||||
- Limit to `push`: `github.event.head_commit.message` is absent on other events.
|
||||
- `curl -fsS` fails the step on HTTP errors while still printing diagnostics.
|
||||
- Auth: if the server needs a token, store it as a secret and add
|
||||
`-H "Authorization: Bearer ${NTFY_TOKEN}"` to the curl call.
|
||||
Reference in New Issue
Block a user