From e9ed21bd4d7c6ecafa31409ecca115f5c6322e6c Mon Sep 17 00:00:00 2001 From: beforegolive Date: Thu, 16 Jul 2026 13:48:01 +0800 Subject: [PATCH] =?UTF-8?q?feat(notify-all):=20=E5=8A=A0=20channels=20inpu?= =?UTF-8?q?t=20=E9=80=89=E6=8B=A9=E9=80=9A=E7=9F=A5=E9=80=9A=E9=81=93=20(v?= =?UTF-8?q?1.2.0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新 input: channels: 默认 'both'(同时推 Bark + 发邮件) 可选 'bark'(只推 Bark)/ 'email'(只发邮件) 实现:composite step 加 'if' 条件 Push to Bark: if ${{ inputs.channels != 'email' }} Send email: if ${{ inputs.channels != 'bark' }} 兼容:未传 channels 时默认 both,向后兼容 v1.1.x 用法。 README.md / docker-gitea/docs/ci-actions.md 同步更新。 --- notify-all/README.md | 12 ++++++++++++ notify-all/action.yml | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/notify-all/README.md b/notify-all/README.md index 6a15201..daf231b 100644 --- a/notify-all/README.md +++ b/notify-all/README.md @@ -36,6 +36,7 @@ secret 走 org-level(gitea_admin org 已配)。 | Input | Default | 说明 | |---|---|---| +| `channels` | `both` | 通知通道:`both` / `bark` / `email` | | `title` | `[${{ github.repository }}] ${{ github.workflow }}` | Bark 推送标题 | | `email_subject` | `[gitea-ci] ${{ github.repository }} - ${{ inputs.status }}` | 邮件主题 | | `bark_device_key` | `${{ secrets.BARK_DEVICE_KEY }}` | Bark key(org secret) | @@ -70,6 +71,17 @@ run: http://gitea:3000/gitea_admin//actions/runs/ 业务 repo 不需要再配 secret。 +## 选通道 + +```yaml +- uses: http://gitea:3000/gitea_admin/ci-actions/notify-all@v1.2.0 + with: + status: ${{ needs.build.result }} + channels: email # 只发邮件(不推 Bark) +``` + +可选值:`both`(默认)/ `bark` / `email`。 + ## 内部实现 `notify-all` 是 composite action,内部 chain 调 sibling action: diff --git a/notify-all/action.yml b/notify-all/action.yml index a001c18..eaba8db 100644 --- a/notify-all/action.yml +++ b/notify-all/action.yml @@ -12,6 +12,10 @@ inputs: status: description: 'Build job status (caller passes ${{ needs..result }})' required: true + channels: + description: 'Notification channels: both (default) / bark / email' + required: false + default: 'both' title: description: 'Notification title' required: false @@ -74,7 +78,9 @@ runs: echo "value=${SHORT}" >> "$GITHUB_OUTPUT" # 2. Push to Bark(链式调 sibling action,完整 URL 因为 act_runner 0.2.11 不支持 ./relative) + # 默认走 bark + email (channels=both),可传 channels=bark 只推 bark / channels=email 只发邮件 - name: Push to Bark + if: ${{ inputs.channels != 'email' }} uses: http://gitea:3000/gitea_admin/ci-actions/notify-bark@v1.1.2 with: device_key: ${{ inputs.bark_device_key }} @@ -92,6 +98,7 @@ runs: # 3. Send email - name: Send email + if: ${{ inputs.channels != 'bark' }} uses: http://gitea:3000/gitea_admin/ci-actions/notify-email@v1.1.2 with: smtp_host: ${{ inputs.smtp_host }}