fix(notify): read the workflow_run fields Gitea sends #1

Merged
poli0981 merged 1 commits from fix/gitea-workflow-run into main 2026-11-23 09:30:48 +00:00
9 changed files with 116 additions and 58 deletions

No files matched your search

+11 -4
View File
@@ -14,7 +14,8 @@ name: Reusable — Announce Release to Discord
# uses: poli0981/.github/.gitea/workflows/announce-release.yml@<full-sha> # ops vYYYY.MM.N
# with:
# tag_override: ${{ inputs.tag }}
# secrets: # explicit; `secrets: inherit` is VERIFY on Gitea
# ops_ref: <full-sha> # the same SHA as `uses:`
# secrets: # explicit, as the runbook asks (Gitea also has `inherit`)
# DISCORD_RELEASES_WEBHOOK: ${{ secrets.DISCORD_RELEASES_WEBHOOK }}
# DISCORD_REPO_WEBHOOK: ${{ secrets.DISCORD_REPO_WEBHOOK }}
# DISCORD_PING_ROLE_ID: ${{ secrets.DISCORD_PING_ROLE_ID }}
@@ -23,7 +24,9 @@ name: Reusable — Announce Release to Discord
# (GET {api_url}/repos/{owner}/{repo}/releases/tags/{tag}, same field names as GitHub)
# instead of `gh api`. Gitea releases carry notes + links only (no binaries), so the
# "Downloads" field is normally empty — the links are in the release body.
# VERIFY: the job token can read poli0981/.github from a caller repo (sparse checkout below).
# The job token reads poli0981/.github from a caller repo because that repo is public: Gitea
# gives every job token read access to public repos. Making it private needs the owner-level
# cross-repo Actions setting instead.
on:
workflow_call:
@@ -32,6 +35,10 @@ on:
description: "Optional tag (when re-running manually)"
type: string
default: ""
ops_ref:
description: "Ref of poli0981/.github the notifier script is loaded from: pass the SHA pinned in `uses:`"
type: string
default: "main"
secrets:
DISCORD_RELEASES_WEBHOOK:
required: false
@@ -54,7 +61,7 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: poli0981/.github
ref: main
ref: ${{ inputs.ops_ref }}
path: ops
sparse-checkout: |
.github/scripts
@@ -63,7 +70,7 @@ jobs:
- name: Resolve release data (Gitea API)
id: release
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
GITEA_TOKEN: ${{ github.token }}
API_URL: ${{ github.api_url }}
INPUT_TAG: ${{ inputs.tag_override }}
EVENT_TAG: ${{ github.event.release.tag_name }}
+24 -17
View File
@@ -16,14 +16,17 @@ name: Reusable — Notify CI Failures to Discord
# uses: poli0981/.github/.gitea/workflows/notify-ci-failure.yml@<full-sha> # ops vYYYY.MM.N
# with:
# default_branch: main
# secrets: # explicit; `secrets: inherit` is VERIFY on Gitea
# ops_ref: <full-sha> # the same SHA as `uses:`
# secrets: # explicit, as the runbook asks (Gitea also has `inherit`)
# DISCORD_CI_WEBHOOK: ${{ secrets.DISCORD_CI_WEBHOOK }}
#
# Gitea port 2026-11-23:
# - VERIFY: `workflow_run` triggers and the github.event.workflow_run.* payload on Gitea 28.
# - Gitea's workflow_run payload is not GitHub's (read from the Gitea source, VERIFY on
# 28.4.0): `workflow_run` has no `name` and no `head_commit`, and head_branch is empty
# for tag runs. The workflow name is github.event.workflow.name, the commit title
# workflow_run.display_title, and the ref the end of workflow_run.path ("<file>@<ref>").
# - github.event.repository.default_branch → explicit input `default_branch` (runbook §4.1).
# - VERIFY: the run link built by discord_notify.py ({server_url}/{repo}/actions/runs/{id})
# opens the right run on Gitea.
# - Run link {server_url}/{repo}/actions/runs/{id}: Gitea looks run IDs up first.
on:
workflow_call:
@@ -38,6 +41,10 @@ on:
description: "Caller repo default branch (Gitea may not populate github.event.repository)"
type: string
default: "main"
ops_ref:
description: "Ref of poli0981/.github the notifier script is loaded from: pass the SHA pinned in `uses:`"
type: string
default: "main"
secrets:
DISCORD_CI_WEBHOOK:
required: true
@@ -50,19 +57,19 @@ jobs:
notify:
if: >
github.event.workflow_run.conclusion == 'failure' &&
!startsWith(github.event.workflow_run.name, 'Notify') &&
!startsWith(github.event.workflow_run.name, 'Announce') &&
!startsWith(github.event.workflow.name, 'Notify') &&
!startsWith(github.event.workflow.name, 'Announce') &&
(
inputs.skip_dedicated_workflows == false ||
(
!contains(github.event.workflow_run.name, 'odeQL') &&
!contains(github.event.workflow_run.name, 'ependabot') &&
!contains(github.event.workflow_run.name, 'enovate') &&
!contains(github.event.workflow_run.name, 'ependency') &&
!contains(github.event.workflow_run.name, 'eploy') &&
!contains(github.event.workflow_run.name, 'ages') &&
!contains(github.event.workflow_run.name, 'elease') &&
!contains(github.event.workflow_run.name, 'esktop')
!contains(github.event.workflow.name, 'odeQL') &&
!contains(github.event.workflow.name, 'ependabot') &&
!contains(github.event.workflow.name, 'enovate') &&
!contains(github.event.workflow.name, 'ependency') &&
!contains(github.event.workflow.name, 'eploy') &&
!contains(github.event.workflow.name, 'ages') &&
!contains(github.event.workflow.name, 'elease') &&
!contains(github.event.workflow.name, 'esktop')
)
) &&
(
@@ -83,7 +90,7 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: poli0981/.github
ref: main
ref: ${{ inputs.ops_ref }}
path: ops
sparse-checkout: |
.github/scripts
@@ -92,13 +99,13 @@ jobs:
- name: Post failure to Discord
env:
DISCORD_CI_WEBHOOK: ${{ secrets.DISCORD_CI_WEBHOOK }}
WORKFLOW_NAME: ${{ github.event.workflow_run.name }}
WORKFLOW_NAME: ${{ github.event.workflow.name }}
RUN_ID: ${{ github.event.workflow_run.id }}
RUN_NUMBER: ${{ github.event.workflow_run.run_number }}
RUN_ATTEMPT: ${{ github.event.workflow_run.run_attempt }}
BRANCH: ${{ github.event.workflow_run.head_branch }}
COMMIT_SHA: ${{ github.event.workflow_run.head_sha }}
COMMIT_MESSAGE: ${{ github.event.workflow_run.head_commit.message }}
COMMIT_MESSAGE: ${{ github.event.workflow_run.display_title }}
ACTOR: ${{ github.event.workflow_run.actor.login }}
EVENT_NAME: ${{ github.event.workflow_run.event }}
run: python3 ops/.github/scripts/discord_notify.py failure
+20 -12
View File
@@ -13,6 +13,7 @@ name: Reusable — Notify Deploy Status to Discord
# uses: poli0981/.github/.gitea/workflows/notify-deploy.yml@<full-sha> # ops vYYYY.MM.N
# with:
# deploy_url: https://example.poli0981.dev # live site shown on success (optional)
# ops_ref: <full-sha> # the same SHA as `uses:`
# secrets:
# DISCORD_CI_WEBHOOK: ${{ secrets.DISCORD_CI_WEBHOOK }}
#
@@ -20,7 +21,10 @@ name: Reusable — Notify Deploy Status to Discord
# - The GitHub Pages lookup (`gh api repos/.../pages`) is removed — Pages does not exist on
# Gitea and sites deploy to Cloudflare Workers. Pass the live URL with `deploy_url`.
# - github.event.repository.default_branch → explicit input `default_branch` (runbook §4.1).
# - VERIFY: `workflow_run` triggers and payload on Gitea 28.
# - Gitea's workflow_run payload is not GitHub's (read from the Gitea source, VERIFY on
# 28.4.0): `workflow_run` has no `name` and no `head_commit`, and head_branch is empty
# for tag runs. The workflow name is github.event.workflow.name, the commit title
# workflow_run.display_title, and the ref the end of workflow_run.path ("<file>@<ref>").
on:
workflow_call:
@@ -33,6 +37,10 @@ on:
description: "Caller repo default branch (Gitea may not populate github.event.repository)"
type: string
default: "main"
ops_ref:
description: "Ref of poli0981/.github the notifier script is loaded from: pass the SHA pinned in `uses:`"
type: string
default: "main"
secrets:
DISCORD_CI_WEBHOOK:
required: true
@@ -46,14 +54,14 @@ jobs:
if: >
(github.event.workflow_run.conclusion == 'success' || github.event.workflow_run.conclusion == 'failure') &&
(
contains(github.event.workflow_run.name, 'eploy') ||
contains(github.event.workflow_run.name, 'ages') ||
contains(github.event.workflow_run.name, 'ublish')
contains(github.event.workflow.name, 'eploy') ||
contains(github.event.workflow.name, 'ages') ||
contains(github.event.workflow.name, 'ublish')
) &&
!startsWith(github.event.workflow_run.name, 'Notify') &&
!contains(github.event.workflow_run.name, 'odeQL') &&
!contains(github.event.workflow_run.name, 'ependabot') &&
!contains(github.event.workflow_run.name, 'enovate') &&
!startsWith(github.event.workflow.name, 'Notify') &&
!contains(github.event.workflow.name, 'odeQL') &&
!contains(github.event.workflow.name, 'ependabot') &&
!contains(github.event.workflow.name, 'enovate') &&
(
github.event.workflow_run.head_branch == inputs.default_branch ||
github.event.workflow_run.head_branch == 'main' ||
@@ -69,7 +77,7 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: poli0981/.github
ref: main
ref: ${{ inputs.ops_ref }}
path: ops
sparse-checkout: |
.github/scripts
@@ -78,7 +86,7 @@ jobs:
- name: Detect deploy target from workflow name
id: target
env:
WF_NAME: ${{ github.event.workflow_run.name }}
WF_NAME: ${{ github.event.workflow.name }}
run: |
TARGET="Deploy"
# Later matches win. No GitHub Pages on Gitea; sites deploy to Cloudflare Workers.
@@ -95,11 +103,11 @@ jobs:
DEPLOY_STATUS: ${{ github.event.workflow_run.conclusion }}
DEPLOY_TARGET: ${{ steps.target.outputs.target }}
DEPLOY_URL: ${{ github.event.workflow_run.conclusion == 'success' && inputs.deploy_url || '' }}
WORKFLOW_NAME: ${{ github.event.workflow_run.name }}
WORKFLOW_NAME: ${{ github.event.workflow.name }}
RUN_ID: ${{ github.event.workflow_run.id }}
RUN_NUMBER: ${{ github.event.workflow_run.run_number }}
BRANCH: ${{ github.event.workflow_run.head_branch }}
COMMIT_SHA: ${{ github.event.workflow_run.head_sha }}
COMMIT_MESSAGE: ${{ github.event.workflow_run.head_commit.message }}
COMMIT_MESSAGE: ${{ github.event.workflow_run.display_title }}
ACTOR: ${{ github.event.workflow_run.actor.login }}
run: python3 ops/.github/scripts/discord_notify.py deploy
+41 -14
View File
@@ -11,14 +11,26 @@ name: Reusable — Notify Release Pipeline to Discord
# jobs:
# notify:
# uses: poli0981/.github/.gitea/workflows/notify-release-pipeline.yml@<full-sha> # ops vYYYY.MM.N
# with:
# ops_ref: <full-sha> # the same SHA as `uses:`
# secrets:
# DISCORD_RELEASE_PIPELINE_WEBHOOK: ${{ secrets.DISCORD_RELEASE_PIPELINE_WEBHOOK }}
#
# Gitea port 2026-11-23: VERIFY `workflow_run` triggers on Gitea 28 and that head_branch
# carries the tag name (v*) for tag-push runs, as on GitHub.
# Gitea port 2026-11-23:
# - Gitea's workflow_run payload is not GitHub's (read from the Gitea source, VERIFY on
# 28.4.0): `workflow_run` has no `name` and no `head_commit`, and head_branch is empty
# for tag runs. The workflow name is github.event.workflow.name, the commit title
# workflow_run.display_title, and the ref the end of workflow_run.path ("<file>@<ref>").
# - So tag runs are recognised by "@refs/tags/v" in workflow_run.path, and the tag is cut
# from it (step "Resolve release tag").
on:
workflow_call:
inputs:
ops_ref:
description: "Ref of poli0981/.github the notifier script is loaded from: pass the SHA pinned in `uses:`"
type: string
default: "main"
secrets:
DISCORD_RELEASE_PIPELINE_WEBHOOK:
required: true
@@ -31,18 +43,18 @@ jobs:
notify:
if: >
(
contains(github.event.workflow_run.name, 'elease') ||
contains(github.event.workflow_run.name, 'esktop')
contains(github.event.workflow.name, 'elease') ||
contains(github.event.workflow.name, 'esktop')
) &&
!startsWith(github.event.workflow_run.name, 'Notify') &&
!startsWith(github.event.workflow_run.name, 'Announce') &&
!contains(github.event.workflow_run.name, 'odeQL') &&
!contains(github.event.workflow_run.name, 'ependabot') &&
!startsWith(github.event.workflow.name, 'Notify') &&
!startsWith(github.event.workflow.name, 'Announce') &&
!contains(github.event.workflow.name, 'odeQL') &&
!contains(github.event.workflow.name, 'ependabot') &&
(
github.event.workflow_run.event == 'release' ||
github.event.workflow_run.event == 'workflow_dispatch' ||
startsWith(github.event.workflow_run.head_branch, 'v') ||
startsWith(github.event.workflow_run.head_branch, 'desktop-v')
contains(github.event.workflow_run.path, '@refs/tags/v') ||
contains(github.event.workflow_run.path, '@refs/tags/desktop-v')
) &&
(
github.event.workflow_run.conclusion == 'success' ||
@@ -59,7 +71,7 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: poli0981/.github
ref: main
ref: ${{ inputs.ops_ref }}
path: ops
sparse-checkout: |
.github/scripts
@@ -68,7 +80,7 @@ jobs:
- name: Detect packager
id: detect
env:
WF_NAME: ${{ github.event.workflow_run.name }}
WF_NAME: ${{ github.event.workflow.name }}
REPO: ${{ github.repository }}
run: |
PACKAGER=""
@@ -82,13 +94,28 @@ jobs:
esac
echo "packager=$PACKAGER" >> "$GITHUB_OUTPUT"
- name: Resolve release tag
id: tag
env:
WF_PATH: ${{ github.event.workflow_run.path }} # "<file>.yml@<ref>" on Gitea
HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
run: |
set -euo pipefail
# Gitea leaves head_branch empty for tag runs; the ref is the end of workflow_run.path.
ref="${WF_PATH#*@}"
case "$ref" in
refs/tags/*) tag="${ref#refs/tags/}" ;;
*) tag="$HEAD_BRANCH" ;;
esac
echo "tag=$tag" >> "$GITHUB_OUTPUT"
- name: Post release pipeline status
env:
DISCORD_RELEASE_PIPELINE_WEBHOOK: ${{ secrets.DISCORD_RELEASE_PIPELINE_WEBHOOK }}
BUILD_STATUS: ${{ github.event.workflow_run.conclusion }}
BUILD_PLATFORM: ${{ github.event.workflow_run.event }}
BUILD_PACKAGER: ${{ steps.detect.outputs.packager }}
RELEASE_TAG: ${{ github.event.workflow_run.head_branch }}
WORKFLOW_NAME: ${{ github.event.workflow_run.name }}
RELEASE_TAG: ${{ steps.tag.outputs.tag }}
WORKFLOW_NAME: ${{ github.event.workflow.name }}
RUN_ID: ${{ github.event.workflow_run.id }}
run: python3 ops/.github/scripts/discord_notify.py release-build
+3 -2
View File
@@ -39,7 +39,8 @@
# stale feed — the job fails before uploading anything
# - rclone pinned + SHA-256 verified; configured only through env vars, with an empty
# config file so the host-mode Windows runner never picks up a local rclone.conf
# - runs only for tag pushes (refs/tags/v*) or workflow_dispatch (runbook §2 rule 10)
# - runs only on a v* tag: a tag push, or workflow_dispatch started on that tag
# (runbook §2 rule 10), the same guard as the release jobs in the reusables
name: Reusable / Publish to R2
@@ -82,7 +83,7 @@ permissions:
jobs:
publish:
# Release credentials: tag pushes or manual runs only (runbook §2 rule 10)
if: ${{ (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) || github.event_name == 'workflow_dispatch' }}
if: ${{ startsWith(github.ref, 'refs/tags/v') && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') }}
runs-on: ${{ inputs.runs-on }}
timeout-minutes: 30
permissions:
@@ -28,9 +28,9 @@
# R2_RELEASES_SECRET_ACCESS_KEY: ${{ secrets.R2_RELEASES_SECRET_ACCESS_KEY }}
#
# Gitea port 2026-11-23: ubuntu-latest = Docker image docker.gitea.com/runner-images.
# VERIFY on pilot: the nested call `uses: ./.gitea/workflows/publish-r2.yml` must resolve to
# this ops repo at the same commit. If Gitea resolves `./` against the CALLER repo, change it
# to `poli0981/.github/.gitea/workflows/publish-r2.yml@<sha of the same ops tag>`.
# The nested call `uses: ./.gitea/workflows/publish-r2.yml` resolves to THIS ops repo at the
# same commit: Gitea reads `./` against the repo and commit of the file that holds the
# `uses:`, not against the caller repo (read from the Gitea source; VERIFY on 28.4.0).
# Actions pinned to commit SHAs (Renovate keeps them current).
name: Reusable / Chrome Extension
@@ -211,7 +211,7 @@ jobs:
if: ${{ inputs.release && startsWith(github.ref, 'refs/tags/v') && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') }}
permissions:
contents: read
uses: ./.gitea/workflows/publish-r2.yml # VERIFY: resolves to this ops repo (see header)
uses: ./.gitea/workflows/publish-r2.yml # this ops repo, same commit (see header)
with:
app: ${{ needs.package.outputs.app }}
artifact: r2-release
+4 -3
View File
@@ -10,9 +10,10 @@ name: Weekly Digest
# Required repo secrets (set on poli0981/.github):
# DISCORD_DIGEST_WEBHOOK — webhook for #announcements
# OPS_GITEA_TOKEN — Gitea PAT (Settings → Applications), scopes:
# read:repository + read:issue. The job token
# (GITEA_TOKEN) only sees this repo, so it cannot
# aggregate the others.
# read:repository + read:issue + read:user
# (GET /users/{owner}/repos needs user AND repository).
# The job token (GITEA_TOKEN) does not see private
# repos, so it cannot aggregate them.
#
# Run on demand: Actions → Weekly Digest → Run workflow
+8 -2
View File
@@ -441,7 +441,7 @@ def post_weekly_digest() -> int:
Env:
DISCORD_DIGEST_WEBHOOK — webhook for #announcements
OPS_GITEA_TOKEN — Gitea PAT, scopes read:repository + read:issue
OPS_GITEA_TOKEN — Gitea PAT, scopes read:repository + read:issue + read:user
(the job token only sees its own repo)
GH_OWNER — owner username (default: owner part of GITHUB_REPOSITORY)
GITEA_API_URL — API root, e.g. https://git.poli0981.dev/api/v1
@@ -473,7 +473,13 @@ def post_weekly_digest() -> int:
]
# Releases: no cross-repo endpoint, so list them per repo and filter by published_at.
repos = _gitea_paged(base, f"/users/{quote(owner, safe='')}/repos", token)
try:
repos = _gitea_paged(base, f"/users/{quote(owner, safe='')}/repos", token)
except HTTPError as e:
if e.code in (401, 403):
print("[ERROR] OPS_GITEA_TOKEN cannot list the repos: GET /users/{owner}/repos needs "
"the scopes read:user + read:repository.")
return 1
releases_by_repo: dict[str, list[dict]] = defaultdict(list)
for repo in repos:
repo_full = repo.get("full_name", "")
+1
View File
@@ -1,3 +1,4 @@
.idea/
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml