auto-log: fetch failing-job log from Gitea API into the details block

New optional inputs (all default to off / safe):
  - auto-log: when true and details is empty, fetch and render the run's
    failing-job log via /api/v1/repos/<repo>/actions/jobs/<id>/logs.
  - token: defaults to github.token (per-run, repo-scoped). Overridable.
  - log-lines: tail-length fallback when no ::error:: annotation present.

Selection heuristic: if any line has ::error::, return those + 12 lines of
context above each (merged windows). Otherwise the last `log-lines` lines.
Timestamp prefixes (act_runner's leading ISO-8601 + Z) are stripped.

The details block already existed; this just makes it cheap for failure
emails to surface the actual build error inline instead of forcing the
reader to click "view run →".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Donavan Fritz
2026-05-28 14:19:32 -05:00
parent a1a09d988e
commit 591fb5b5d6
3 changed files with 151 additions and 0 deletions
+21
View File
@@ -28,6 +28,24 @@ inputs:
description: Optional multiline preformatted block (rendered in a monospace card). Leave empty to omit.
required: false
default: ''
auto-log:
description: |
If 'true' AND details is empty, fetch the current run's failing-job log via the
Gitea API and render the relevant tail as the details block. Useful for failure
notifications so the email shows the actual error inline. Requires `token`.
required: false
default: 'false'
token:
description: |
Gitea API token used to fetch the run log when `auto-log: true`. Defaults to
the run's per-job GITHUB_TOKEN which has read access to the current repo's
actions. Pass `${{ secrets.CI_BOT_TOKEN }}` only if GITHUB_TOKEN isn't enough.
required: false
default: ${{ github.token }}
log-lines:
description: How many tail lines of the failing step to include when no `::error::` annotation is found.
required: false
default: '40'
smtp-host:
description: SMTP relay host.
required: false
@@ -48,6 +66,9 @@ runs:
NOTIFY_SUBJECT: ${{ inputs.subject }}
NOTIFY_SUMMARY: ${{ inputs.summary }}
NOTIFY_DETAILS: ${{ inputs.details }}
NOTIFY_AUTO_LOG: ${{ inputs.auto-log }}
NOTIFY_TOKEN: ${{ inputs.token }}
NOTIFY_LOG_LINES: ${{ inputs.log-lines }}
NOTIFY_SMTP_HOST: ${{ inputs.smtp-host }}
NOTIFY_SMTP_PORT: ${{ inputs.smtp-port }}
GH_SERVER_URL: ${{ github.server_url }}