Auto-Link and Auto-Close Issues on PRs to Dev Branches (dev-2.0)
Issue: #7975 Pull Requests:
Problem
GitHub’s built-in auto-close behavior (Fixes #, Closes #) only works for PRs merged into the default branch. This created issues:
- PRs into
2.0ordev-2.0didn't auto-link or auto-close issues - Contributors had to manually close referenced issues
- Example: PR #7971 failed to close Issue #7905
Objective
- Create a GitHub Action that runs when PRs are merged into
2.0ordev-2.0 - Parse PR body for issue-closing keywords
- Automatically close referenced issues via GitHub API
Solution
- Wrote
.github/workflows/auto-close-issues.ymlin bothp5.jsandp5.js-website - Script parses PR descriptions and extracts issue references
- Sends POST requests to GitHub API to close those issues
- Uses secure
GITHUB_TOKENfor authentication - Logs warnings for malformed/missing issue references
Outcome
- Issues auto-close on PR merges into non-default branches (like
dev-2.0) - No manual issue management needed by contributors
- Cleaner project boards and faster feedback loops
Technical Challenges
- GitHub doesn't support this behavior natively for non-default branches
- Required manual parsing and API calls to close issues
- Handled edge cases like malformed PR descriptions, missing references, and multiple issue links