Skip to content

Commit a10726f

Browse files
committed
feat(ci): post coverage gap issue to both TechEngine and TechAPI
Finish the token-name cleanup in coverage-report.yml (TECHAPI_PR_TOKEN -> TECHAPI_TOKEN) and post the sticky coverage issue to BOTH repos: TechEngine via GITHUB_TOKEN (works today) and TechAPI via TECHAPI_TOKEN. The TechAPI post is best-effort and warns instead of failing when the PAT lacks Issues:write, so the weekly run never breaks.
1 parent 479ec93 commit a10726f

1 file changed

Lines changed: 28 additions & 14 deletions

File tree

.github/workflows/coverage-report.yml

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,35 @@ jobs:
4141
name: coverage-report
4242
path: coverage-report.md
4343

44-
# Sticky issue: search for an open issue with the well-known title and
45-
# update it; create one if missing. Defaults to this repo; if a PAT
46-
# scoped to TechAPI is provided as TECHAPI_PR_TOKEN, posts there instead.
47-
- name: Sync sticky coverage issue
44+
# Sticky issue: keep one open issue with the well-known title per repo,
45+
# updating it in place. Posts to BOTH TechEngine (default GITHUB_TOKEN) and
46+
# TechAPI (TECHAPI_TOKEN). The TechAPI post is best-effort: it needs the PAT
47+
# to carry Issues:write, so a missing permission warns instead of failing.
48+
- name: Sync sticky coverage issue (TechEngine + TechAPI)
4849
env:
49-
GH_TOKEN: ${{ secrets.TECHAPI_PR_TOKEN || secrets.GITHUB_TOKEN }}
50-
TARGET_REPO: ${{ secrets.TECHAPI_PR_TOKEN && 'Seungpyo1007/TechAPI' || github.repository }}
50+
SELF_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
TECHAPI_TOKEN: ${{ secrets.TECHAPI_TOKEN }}
5152
run: |
52-
set -euo pipefail
53+
set -uo pipefail
5354
TITLE="Coverage gaps (auto-generated)"
5455
BODY="$(cat coverage-report.md)"
55-
NUMBER=$(gh issue list --repo "$TARGET_REPO" --state open \
56-
--search "in:title \"$TITLE\"" --json number --jq '.[0].number // empty')
57-
if [ -z "${NUMBER:-}" ]; then
58-
gh issue create --repo "$TARGET_REPO" --title "$TITLE" --body "$BODY"
59-
else
60-
gh issue edit "$NUMBER" --repo "$TARGET_REPO" --body "$BODY"
61-
fi
56+
sync_issue() {
57+
repo="$1"; token="$2"
58+
if [ -z "$token" ]; then
59+
echo "::warning::no token for $repo; skipping coverage issue"
60+
return 0
61+
fi
62+
NUMBER=$(GH_TOKEN="$token" gh issue list --repo "$repo" --state open \
63+
--search "in:title \"$TITLE\"" --json number --jq '.[0].number // empty') || return 1
64+
if [ -z "${NUMBER:-}" ]; then
65+
GH_TOKEN="$token" gh issue create --repo "$repo" --title "$TITLE" --body "$BODY"
66+
else
67+
GH_TOKEN="$token" gh issue edit "$NUMBER" --repo "$repo" --body "$BODY"
68+
fi
69+
}
70+
# TechEngine: default token has issues:write on this repo.
71+
sync_issue "${{ github.repository }}" "$SELF_TOKEN" \
72+
|| echo "::warning::TechEngine coverage issue sync failed"
73+
# TechAPI: best-effort — requires Issues:write on TECHAPI_TOKEN.
74+
sync_issue "Seungpyo1007/TechAPI" "$TECHAPI_TOKEN" \
75+
|| echo "::warning::TechAPI coverage issue sync failed — TECHAPI_TOKEN likely lacks Issues:write"

0 commit comments

Comments
 (0)