fix: manage report issue lifecycle based on violations#12
fix: manage report issue lifecycle based on violations#12botantler[bot] merged 1 commit intomainfrom
Conversation
Replace the step-security/create-issue-from-file action with a shared composite action that uses the gh CLI to manage the full issue lifecycle: - Violations found: create new issue, or update + reopen existing - No violations: close existing open issue, or do nothing This prevents noisy issues when no violations exist and avoids duplicate issues when violations recur after an issue was closed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR improves GitHub organization maintenance report workflows by managing the lifecycle of the corresponding GitHub issue based on whether violations are present, avoiding noisy “all good” issues and preventing duplicates when violations recur.
Changes:
- Added a new composite action to create/update/reopen/close report issues using the
ghCLI based on ahas-violationsflag. - Updated all report workflows to use the new composite action instead of
step-security/create-issue-from-file. - Wired existing report outputs (
report-path,has-violations) into the workflows’ issue-management step.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| .github/workflows/report-repos-with-no-team.yml | Switches issue publishing to the new lifecycle-based composite action. |
| .github/workflows/report-repos-with-no-admin-team.yml | Switches issue publishing to the new lifecycle-based composite action. |
| .github/workflows/report-repos-with-multi-admin-teams.yml | Switches issue publishing to the new lifecycle-based composite action. |
| .github/actions/manage-report-issue/action.yml | Implements issue create/update/reopen/close logic driven by has-violations. |
| --state all \ | ||
| --search "in:title \"${TITLE}\"" \ | ||
| --json number,title \ | ||
| --jq ".[] | select(.title == \"${TITLE}\") | .number" \ |
There was a problem hiding this comment.
The jq filter interpolates TITLE directly into a quoted jq string (select(.title == "${TITLE}")). If the title ever contains a double-quote or backslash, this will produce invalid jq and fail the action. Use jq's --arg to pass TITLE safely and compare against $title instead of string interpolation.
| --jq ".[] | select(.title == \"${TITLE}\") | .number" \ | |
| | jq -r --arg title "$TITLE" '.[] | select(.title == $title) | .number' \ |
| # Find existing issue by exact title (any state) | ||
| ISSUE_NUMBER=$( | ||
| gh issue list \ | ||
| --repo "$GITHUB_REPOSITORY" \ | ||
| --state all \ | ||
| --search "in:title \"${TITLE}\"" \ | ||
| --json number,title \ | ||
| --jq ".[] | select(.title == \"${TITLE}\") | .number" \ | ||
| | head -1 | ||
| ) | ||
|
|
There was a problem hiding this comment.
gh issue list is called without an explicit --limit, so it will only consider the CLI's default number of results. If there are many historical issues with the same title, the correct match (especially an older open one) may not be returned, which can reintroduce duplicate-issue behavior. Set an explicit limit (and/or prefer open issues first) to make selection deterministic.
| # Find existing issue by exact title (any state) | |
| ISSUE_NUMBER=$( | |
| gh issue list \ | |
| --repo "$GITHUB_REPOSITORY" \ | |
| --state all \ | |
| --search "in:title \"${TITLE}\"" \ | |
| --json number,title \ | |
| --jq ".[] | select(.title == \"${TITLE}\") | .number" \ | |
| | head -1 | |
| ) | |
| # Find existing issue by exact title, preferring an open issue over a closed one. | |
| ISSUE_NUMBER=$( | |
| gh issue list \ | |
| --repo "$GITHUB_REPOSITORY" \ | |
| --state open \ | |
| --limit 1000 \ | |
| --search "in:title \"${TITLE}\"" \ | |
| --json number,title \ | |
| --jq ".[] | select(.title == \"${TITLE}\") | .number" \ | |
| | head -1 | |
| ) | |
| if [ -z "$ISSUE_NUMBER" ]; then | |
| ISSUE_NUMBER=$( | |
| gh issue list \ | |
| --repo "$GITHUB_REPOSITORY" \ | |
| --state closed \ | |
| --limit 1000 \ | |
| --search "in:title \"${TITLE}\"" \ | |
| --json number,title \ | |
| --jq ".[] | select(.title == \"${TITLE}\") | .number" \ | |
| | head -1 | |
| ) | |
| fi |
Summary
Fixes the issue where all report workflows unconditionally create/update a GitHub issue — even when no violations are found — and create duplicate issues when violations recur after a previous issue was closed.
Changes
.github/actions/manage-report-issue/action.yml) — usesghCLI to manage the full issue lifecycle:step-security/create-issue-from-fileBehavior matrix
No TypeScript changes — the
has-violationsandreport-pathoutputs already existed inwriteReportOutput.