diff --git a/.github/scripts/bark-notify.sh b/.github/scripts/bark-notify.sh new file mode 100755 index 0000000..e1013ee --- /dev/null +++ b/.github/scripts/bark-notify.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +# bark-notify.sh — push a notification to the local Bark server. +# +# Usage: bark-notify.sh <body> +# +# The Bark endpoint, device_key, and group are pinned in this script +# (it is a deployment detail, not a secret). The group is "Gitea" — +# change it here if you want to sort notifications by category. + +set -euo pipefail + +if [ "$#" -ne 2 ]; then + echo "usage: $0 <title> <body>" >&2 + exit 1 +fi + +TITLE="$1" +BODY="$2" + +PAYLOAD=$(cat <<EOF +{ + "device_key": "6ZFVsxM95cuAjYoNLWSWaN", + "title": "${TITLE}", + "body": "${BODY}", + "group": "Gitea", + "isArchive": 1, + "ttl": 3600 +} +EOF +) + +curl -s \ + -X POST http://101.43.40.124:81/push \ + -H "Content-Type: application/json; charset=utf-8" \ + -d "${PAYLOAD}" + +echo "bark notified: ${TITLE}" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fee3ece..9a464ce 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -60,21 +60,7 @@ jobs: EMOJI="❌" fi BODY="${EMOJI} ${REF_NAME} ${STATUS}: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${{ github.run_id }}" - PAYLOAD=$(cat <<EOF - { - "device_key": "6ZFVsxM95cuAjYoNLWSWaN", - "title": "CI ${REF_NAME} ${STATUS}", - "body": "${BODY}", - "group": "Gitea", - "isArchive": 1, - "ttl": 3600 - } - EOF - ) - curl -s \ - -X POST http://101.43.40.124:81/push \ - -H "Content-Type: application/json; charset=utf-8" \ - -d "${PAYLOAD}" + bash .github/scripts/bark-notify.sh "CI ${REF_NAME} ${STATUS}" "${BODY}" release: name: Release @@ -143,18 +129,4 @@ jobs: EMOJI="❌" fi BODY="${EMOJI} spark-mcp ${TITLE} ${STATUS}: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/releases/tag/${TITLE}" - PAYLOAD=$(cat <<EOF - { - "device_key": "6ZFVsxM95cuAjYoNLWSWaN", - "title": "${TITLE} ${STATUS}", - "body": "${BODY}", - "group": "Gitea", - "isArchive": 1, - "ttl": 3600 - } - EOF - ) - curl -s \ - -X POST http://101.43.40.124:81/push \ - -H "Content-Type: application/json; charset=utf-8" \ - -d "${PAYLOAD}" + bash .github/scripts/bark-notify.sh "${TITLE} ${STATUS}" "${BODY}"