From 1ff0b7c3dce7a70f33ce2c0dcfd07c01f7cb4f26 Mon Sep 17 00:00:00 2001 From: endercodezz Date: Fri, 6 Nov 2026 17:15:41 +0200 Subject: [PATCH] fix(ci): close the issues of auto-merged pull requests Closes #n does nothing here: auto-merge runs as github-actions with GITHUB_TOKEN, and #80 and #3 stayed open after their pull requests merged. That merge starts no workflow either, so a scheduled one closes the open issues of merged pull requests and leaves reopened ones alone. Verified: the same query run read-only finds no wrong issue to close. --- .github/workflows/close-linked-issues.yml | 33 +++++++++++++++++++++++ AGENTS.md | 2 +- CLAUDE.md | 2 +- 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/close-linked-issues.yml diff --git a/.github/workflows/close-linked-issues.yml b/.github/workflows/close-linked-issues.yml new file mode 100644 index 00000000..bdce7c3c --- /dev/null +++ b/.github/workflows/close-linked-issues.yml @@ -0,0 +1,33 @@ +# Closes the issues of merged pull requests (`Closes #n`). GitHub does not do it +# here: auto-merge runs as github-actions with GITHUB_TOKEN, and such a merge +# neither processes closing keywords nor starts a workflow on pull_request closed, +# so this runs on a schedule. An issue reopened by hand stays open. +name: Close linked issues + +on: + schedule: + - cron: '*/30 * * * *' + workflow_dispatch: + +permissions: + issues: write + pull-requests: read + +jobs: + close: + name: Close issues of merged pull requests + runs-on: ubuntu-24.04 + steps: + - name: gh issue close + env: + GH_TOKEN: ${{ github.token }} + REPO: ${{ github.repository }} + run: | + gh pr list -R "$REPO" --state merged --limit 50 --json number,closingIssuesReferences \ + --jq '.[] | .number as $pr | .closingIssuesReferences[] | "\(.number) \($pr)"' | + while read -r issue pr; do + state=$(gh api "repos/$REPO/issues/$issue" --jq '"\(.state) \(.state_reason)"') + if [ "$state" = "open null" ]; then + gh issue close "$issue" -R "$REPO" --comment "Closed by #$pr." + fi + done diff --git a/AGENTS.md b/AGENTS.md index b92d21d8..3fe798e3 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -233,7 +233,7 @@ Every task is tracked by a GitHub issue and lands in `master` through a pull req 1. The working tree contains modifications belonging to the task; 2. All regression, verification, and smoke tests have passed cleanly; 3. There is no explicit instruction from the user forbidding commits. -4. **Push** the branch (`git push -u origin `) and **open a pull request** into `master` whose body says what changed, how it was verified, and `Closes #`. CI runs on the pull request. +4. **Push** the branch (`git push -u origin `) and **open a pull request** into `master` whose body says what changed, how it was verified, and `Closes #`. CI runs on the pull request. GitHub does not process `Closes` for auto-merges, so `.github/workflows/close-linked-issues.yml` closes those issues within about 30 minutes; an issue reopened by hand stays open. 5. **Merge**: a pull request opened by `endercodezz` (also the ones the agent opens with the maintainer's `gh` login) is **auto-merged** with a merge commit once the required CI checks pass (`.github/workflows/automerge.yml`; `master` requires `Linux host build + tests`, `Windows host build + tests`, `New 3DS runtime (devkitARM)`, `texpack (Rust)`, and `BinDiff` and `CPK tool` on both systems; the last two have the Zig version in their names, so a Zig update renames the required checks too). So open a pull request only for verified, finished work; work in progress is opened as a draft (`gh pr create --draft`), which is not auto-merged; `gh pr merge --disable-auto` stops a pending auto-merge. Other pull requests (contributors) are merged by the maintainer; the agent merges them only when the user says so. Always a merge commit, never squash or rebase (section 17). Releases are tagged on `master` after the merge. Never stage temporary files, `.claude/LOCAL.md`, credentials or game assets. The procedure and its pre/post-commit check scripts are in the `p3p3ds-commit` skill. diff --git a/CLAUDE.md b/CLAUDE.md index 6798ef7a..7c315be4 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -199,7 +199,7 @@ Every task is tracked by a GitHub issue and lands in `master` through a pull req 1. The working tree contains modifications belonging to the task; 2. All regression, verification, and smoke tests have passed cleanly; 3. There is no explicit instruction from the user forbidding commits. -4. **Push** the branch (`git push -u origin `) and **open a pull request** into `master` whose body says what changed, how it was verified, and `Closes #`. CI runs on the pull request. +4. **Push** the branch (`git push -u origin `) and **open a pull request** into `master` whose body says what changed, how it was verified, and `Closes #`. CI runs on the pull request. GitHub does not process `Closes` for auto-merges, so `.github/workflows/close-linked-issues.yml` closes those issues within about 30 minutes; an issue reopened by hand stays open. 5. **Merge**: a pull request opened by `endercodezz` (also the ones the agent opens with the maintainer's `gh` login) is **auto-merged** with a merge commit once the required CI checks pass (`.github/workflows/automerge.yml`; `master` requires `Linux host build + tests`, `Windows host build + tests`, `New 3DS runtime (devkitARM)`, `texpack (Rust)`, and `BinDiff` and `CPK tool` on both systems; the last two have the Zig version in their names, so a Zig update renames the required checks too). So open a pull request only for verified, finished work; work in progress is opened as a draft (`gh pr create --draft`), which is not auto-merged; `gh pr merge --disable-auto` stops a pending auto-merge. Other pull requests (contributors) are merged by the maintainer; the agent merges them only when the user says so. Always a merge commit, never squash or rebase (section 17). Releases are tagged on `master` after the merge. Never stage temporary files, `.claude/LOCAL.md`, credentials or game assets. The procedure and its pre/post-commit check scripts are in the `p3p3ds-commit` skill.