feat(notify-bark): composite action 推送 Gitea Actions 结果到 Bark
This commit is contained in:
@@ -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。
|
||||||
@@ -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
|
||||||
Reference in New Issue
Block a user