52 lines
1.6 KiB
YAML
52 lines
1.6 KiB
YAML
name: Notification
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
job_status:
|
|
required: true
|
|
type: string
|
|
job_name:
|
|
required: true
|
|
type: string
|
|
secrets:
|
|
NTFY_TOPIC: { required: true }
|
|
NTFY_TOKEN: { required: true }
|
|
NTFY_SERVER: { required: true }
|
|
|
|
jobs:
|
|
notify:
|
|
runs-on: docker
|
|
steps:
|
|
- name: Send Notification
|
|
shell: bash
|
|
run: |
|
|
# Icon und Titel basierend auf Status
|
|
if [ "${{ inputs.job_status }}" == "success" ]; then
|
|
ICON="✅"
|
|
TITLE="Fixed: ${{ inputs.job_name }} for ${{ gitea.repository }}"
|
|
else
|
|
ICON="❌"
|
|
TITLE="Failed: ${{ inputs.job_name }} for ${{ gitea.repository }}"
|
|
fi
|
|
|
|
COMMIT_SUBJECT="$(git log -1 --pretty=%s || echo 'Commit info unavailable')"
|
|
RUN_URL="${{ gitea.server_url }}/${{ gitea.repository }}/actions/runs/${{ gitea.run_number }}"
|
|
|
|
cat <<EOF >/tmp/ntfy-payload.json
|
|
{
|
|
"topic": "${{ secrets.NTFY_TOPIC }}",
|
|
"title": "${ICON} ${TITLE}",
|
|
"message": "Ref: ${{ gitea.ref_name }}\nCommit: ${COMMIT_SUBJECT}\n\nRun URL: ${RUN_URL}",
|
|
"click": "${RUN_URL}",
|
|
"actions": [
|
|
{ "action": "view", "label": "Open Run", "url": "${RUN_URL}" }
|
|
]
|
|
}
|
|
EOF
|
|
|
|
curl -fsS \
|
|
-H "Authorization: Bearer ${{ secrets.NTFY_TOKEN }}" \
|
|
-H "Content-Type: application/json" \
|
|
-d @/tmp/ntfy-payload.json \
|
|
"${{ secrets.NTFY_SERVER }}" |