feat(notify-all): sha 字段截短到前 10 位(git short SHA)
This commit is contained in:
+13
-1
@@ -37,7 +37,6 @@ secret 走 org-level(gitea_admin org 已配)。
|
||||
| Input | Default | 说明 |
|
||||
|---|---|---|
|
||||
| `title` | `[${{ github.repository }}] ${{ github.workflow }}` | Bark 推送标题 |
|
||||
| `body` | 自动拼 status / branch / commit / sha / actor / run | 通知正文(Bark + Email 共用) |
|
||||
| `email_subject` | `[gitea-ci] ${{ github.repository }} - ${{ inputs.status }}` | 邮件主题 |
|
||||
| `bark_device_key` | `${{ secrets.BARK_DEVICE_KEY }}` | Bark key(org secret) |
|
||||
| `bark_server` | `https://api.day.app` | Bark server(自建时改) |
|
||||
@@ -49,6 +48,19 @@ secret 走 org-level(gitea_admin org 已配)。
|
||||
| `smtp_pass` | `${{ secrets.EMAIL_SMTP_PASS }}` | SMTP 授权码(org secret) |
|
||||
| `to` | `${{ secrets.EMAIL_TO }}` | 收件邮箱(org secret) |
|
||||
|
||||
> body 不再是 input(v1.1.2 起),由 notify-all 自动拼(status / branch / commit / **sha 前 10 位** / actor / run)。如需自定义 body,绕开 notify-all 直接用 notify-bark + notify-email。
|
||||
|
||||
## 自动拼的 body 格式
|
||||
|
||||
```
|
||||
status: success
|
||||
branch: main
|
||||
commit: ci: any commit message
|
||||
sha: 29a4454e0 # ← 只取前 10 位
|
||||
actor: gitea_admin
|
||||
run: http://gitea:3000/gitea_admin/<repo>/actions/runs/<id>
|
||||
```
|
||||
|
||||
## 依赖的 org-level secret(gitea_admin org 已配)
|
||||
|
||||
- `BARK_DEVICE_KEY`
|
||||
|
||||
+34
-22
@@ -2,12 +2,11 @@ name: 'Notify All'
|
||||
description: 'Bark push + email in one step. Zero-config when paired with org/instance-level secrets.'
|
||||
author: 'gitea_admin'
|
||||
|
||||
# 设计要点(2026-07-15):
|
||||
# - title / body / subject 等全用 github.* + inputs.status 自动拼,业务 repo 只需传 status
|
||||
# - secret 默认走 org-level(gitea_admin org 已配 BARK_DEVICE_KEY / EMAIL_USER /
|
||||
# EMAIL_SMTP_PASS / EMAIL_TO 4 个 secret),业务 repo 0 secret 配置
|
||||
# - Bark + Email 两个 step 在内部 chain 调 sibling action(./notify-bark / ./notify-email),
|
||||
# 避免业务 repo 写两个 step
|
||||
# v1.1.2 改动(2026-07-15):
|
||||
# - sha 字段截短到前 10 位(git short SHA 标准)
|
||||
# - 因为 input default 在 composite 开始时 evaluate,引用不到 steps.output,
|
||||
# 所以把 body 从 input default 移到 step with 里(直接用 ${{ steps.short_sha.outputs.value }})
|
||||
# - 删 body input —— 业务侧不能 override body;如要自定义可走 notify-bark/notify-email 直引
|
||||
|
||||
inputs:
|
||||
status:
|
||||
@@ -17,16 +16,6 @@ inputs:
|
||||
description: 'Notification title'
|
||||
required: false
|
||||
default: "[${{ github.repository }}] ${{ github.workflow }}"
|
||||
body:
|
||||
description: 'Notification body (auto-built if not provided)'
|
||||
required: false
|
||||
default: |
|
||||
status: ${{ inputs.status }}
|
||||
branch: ${{ github.ref_name }}
|
||||
commit: ${{ github.event.head_commit.message }}
|
||||
sha: ${{ github.event.head_commit.id }}
|
||||
actor: ${{ github.actor }}
|
||||
run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||
email_subject:
|
||||
description: 'Email subject'
|
||||
required: false
|
||||
@@ -75,20 +64,35 @@ inputs:
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
# 链式调用 sibling action。act_runner 0.2.11 不支持 ./relative path,
|
||||
# 必须用完整 URL。tag 跟 notify-all 自己同一个 tag,确保三个 action 自包含。
|
||||
# 1. 算 short SHA(git 标准 10 位)。Gitea 表达式没 slice/substring 函数,必须用 shell
|
||||
- name: Compute short SHA
|
||||
id: short_sha
|
||||
shell: bash
|
||||
run: |
|
||||
SHA="${{ github.event.head_commit.id }}"
|
||||
SHORT="${SHA:0:10}"
|
||||
echo "value=${SHORT}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# 2. Push to Bark(链式调 sibling action,完整 URL 因为 act_runner 0.2.11 不支持 ./relative)
|
||||
- name: Push to Bark
|
||||
uses: http://gitea:3000/gitea_admin/ci-actions/notify-bark@v1.1.1
|
||||
uses: http://gitea:3000/gitea_admin/ci-actions/notify-bark@v1.1.2
|
||||
with:
|
||||
device_key: ${{ inputs.bark_device_key }}
|
||||
server: ${{ inputs.bark_server }}
|
||||
title: ${{ inputs.title }}
|
||||
body: ${{ inputs.body }}
|
||||
body: |
|
||||
status: ${{ inputs.status }}
|
||||
branch: ${{ github.ref_name }}
|
||||
commit: ${{ github.event.head_commit.message }}
|
||||
sha: ${{ steps.short_sha.outputs.value }}
|
||||
actor: ${{ github.actor }}
|
||||
run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||
group: ${{ inputs.bark_group }}
|
||||
level: ${{ inputs.bark_level }}
|
||||
|
||||
# 3. Send email
|
||||
- name: Send email
|
||||
uses: http://gitea:3000/gitea_admin/ci-actions/notify-email@v1.1.1
|
||||
uses: http://gitea:3000/gitea_admin/ci-actions/notify-email@v1.1.2
|
||||
with:
|
||||
smtp_host: ${{ inputs.smtp_host }}
|
||||
smtp_port: ${{ inputs.smtp_port }}
|
||||
@@ -96,4 +100,12 @@ runs:
|
||||
smtp_pass: ${{ inputs.smtp_pass }}
|
||||
to: ${{ inputs.to }}
|
||||
subject: ${{ inputs.email_subject }}
|
||||
body: ${{ inputs.body }}
|
||||
body: |
|
||||
repository: ${{ github.repository }}
|
||||
workflow: ${{ github.workflow }}
|
||||
status: ${{ inputs.status }}
|
||||
branch: ${{ github.ref_name }}
|
||||
commit: ${{ github.event.head_commit.message }}
|
||||
sha: ${{ steps.short_sha.outputs.value }}
|
||||
url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||
actor: ${{ github.actor }}
|
||||
Reference in New Issue
Block a user