Files
gentoo-zh/scripts/upsert-comment.sh
T
Zakk 5cefccb26c .github/workflows: move trial and pkgcheck comment logic into scripts
Because the engine returns to master, restore the dispatched ref so
every trial target uses the selected scripts. Reuse the worker image
because it already supplies the trial setup and tools.

A skipped report job leaves no artifact, so skip its download and comment
instead of failing the comment workflow. Select a marker across all
comment pages because per-page lookup can return several comment IDs.

Signed-off-by: Zakk <zakk@gentoozh.org>
2026-10-02 01:54:16 +10:00

20 lines
635 B
Bash
Executable File

#!/usr/bin/env bash
# usage: upsert-comment.sh <repository> <issue> <marker> <body-file>
set -euo pipefail
repository=${1:?repository}
issue=${2:?issue}
marker=${3:?marker}
body_file=${4:?body-file}
comments=$(gh api "repos/$repository/issues/$issue/comments" --paginate --slurp)
comment_id=$(jq -r --arg marker "$marker" '
[.[][] | select(.body | contains($marker))][0].id // empty
' <<< "$comments")
if [ -n "$comment_id" ]; then
gh api -X PATCH "repos/$repository/issues/comments/$comment_id" -F "body=@$body_file" >/dev/null
else
gh api "repos/$repository/issues/$issue/comments" -F "body=@$body_file" >/dev/null
fi