From 2e99202570e283864e3c0726572136e80f5883c9 Mon Sep 17 00:00:00 2001 From: gitea_admin Date: Mon, 13 Jul 2026 09:29:01 +0800 Subject: [PATCH] =?UTF-8?q?feat(notify-bark):=20composite=20action=20?= =?UTF-8?q?=E6=8E=A8=E9=80=81=20Gitea=20Actions=20=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E5=88=B0=20Bark?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- notify-bark/README.md | 30 ++++++++++++++++++++++++++ notify-bark/action.yml | 48 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 notify-bark/README.md create mode 100644 notify-bark/action.yml diff --git a/notify-bark/README.md b/notify-bark/README.md new file mode 100644 index 0000000..b6b974a --- /dev/null +++ b/notify-bark/README.md @@ -0,0 +1,30 @@ +# notify-bark + +推送 Gitea Actions run 结果到 [Bark](https://github.com/Finb/Bark) iOS 客户端。 + +## Inputs + +| 名称 | 必填 | 默认 | 说明 | +|---|---|---|---| +| `device_key` | 是 | — | Bark 设备 key | +| `server` | 否 | `https://api.day.app` | Bark server URL | +| `title` | 是 | — | 推送标题 | +| `body` | 是 | — | 推送正文(支持多行) | +| `group` | 否 | `gitea-ci` | 通知分组 | +| `level` | 否 | `active` | `active` / `timeSensitive` / `passive` / `default` | + +## 使用示例 + +```yaml +- uses: gitea_admin/ci-actions/notify-bark@v1 + with: + device_key: ${{ secrets.BARK_DEVICE_KEY }} + title: "[${{ github.repository }}] ${{ github.workflow }}" + body: | + status: ${{ needs.build.result }} + run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} +``` + +## 失败处理 + +推送失败时输出 `::warning::Bark push failed (non-fatal)`,**不阻塞**调用方 job。 \ No newline at end of file diff --git a/notify-bark/action.yml b/notify-bark/action.yml new file mode 100644 index 0000000..86406f6 --- /dev/null +++ b/notify-bark/action.yml @@ -0,0 +1,48 @@ +name: 'Notify Bark' +description: 'Send Gitea Actions run result to Bark iOS push' +author: 'gitea_admin' + +inputs: + device_key: + description: 'Bark device key' + required: true + server: + description: 'Bark server URL (no trailing slash)' + required: false + default: 'https://api.day.app' + title: + description: 'Notification title' + required: true + body: + description: 'Notification body (multiline OK)' + required: true + group: + description: 'Notification group' + required: false + default: 'gitea-ci' + level: + description: 'Bark level (active/timeSensitive/passive/default)' + required: false + default: 'active' + +runs: + using: 'composite' + steps: + - name: Send Bark push + shell: bash + env: + BARK_SERVER: ${{ inputs.server }} + DEVICE_KEY: ${{ inputs.device_key }} + TITLE: ${{ inputs.title }} + BODY: ${{ inputs.body }} + GROUP: ${{ inputs.group }} + LEVEL: ${{ inputs.level }} + run: | + set -u + # URL encode title / body + TITLE_ENC=$(printf '%s' "$TITLE" | jq -sRr @uri) + BODY_ENC=$(printf '%s' "$BODY" | jq -sRr @uri) + URL="${BARK_SERVER}/${DEVICE_KEY}/${TITLE_ENC}/${BODY_ENC}?group=${GROUP}&level=${LEVEL}" + if ! curl -fsS --max-time 10 --retry 2 "$URL" >/dev/null; then + echo "::warning::Bark push failed (non-fatal): $URL" + fi \ No newline at end of file