feat(notify-all): sha 字段截短到前 10 位(git short SHA)
lint / yamllint (push) Successful in 13s

This commit is contained in:
beforegolive
2026-07-16 09:00:38 +08:00
parent 1ec372142c
commit 224f5bdd78
2 changed files with 47 additions and 23 deletions
+34 -22
View File
@@ -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-levelgitea_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 SHAgit 标准 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 }}