Add GitHub workflows for PR validation and issue closure#20
Merged
OGR-67 merged 1 commit intoMar 17, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces GitHub Actions workflows to enforce PR hygiene (issue linkage) and branching rules, and to automatically close referenced issues when PRs are merged into dev (addressing Issue #19).
Changes:
- Add a PR validation workflow that fails if the PR body doesn’t reference an issue via
closes/fixes/resolves #<n>. - Add a workflow to restrict PRs targeting
mainto only those coming from adevsource branch. - Add a workflow to auto-close referenced issues when a PR is merged into
dev, plus a PR template prompting authors to includecloses #....
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
.github/workflows/validate-pr.yml |
Enforces presence of an issue-closing reference in PR body. |
.github/workflows/restrict-main-source.yml |
Blocks PRs to main unless the source branch is dev. |
.github/workflows/close-issues-on-dev.yml |
On merge to dev, parses PR body and closes referenced issues via GitHub API. |
.github/pull_request_template.md |
Adds a template section prompting closes #... in PR descriptions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+8
to
+27
| jobs: | ||
| close-issues: | ||
| if: github.event.pull_request.merged == true | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const body = context.payload.pull_request.body || ''; | ||
| const matches = [...body.matchAll(/(?:closes|fixes|resolves)\s+#(\d+)/gi)]; | ||
|
|
||
| if (matches.length === 0) return; | ||
|
|
||
| for (const match of matches) { | ||
| const issueNumber = parseInt(match[1]); | ||
| await github.rest.issues.update({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: issueNumber, | ||
| state: 'closed' |
Comment on lines
+21
to
+22
| for (const match of matches) { | ||
| const issueNumber = parseInt(match[1]); |
Comment on lines
+3
to
+14
| on: | ||
| pull_request: | ||
| types: [closed] | ||
| branches: [dev] | ||
|
|
||
| jobs: | ||
| close-issues: | ||
| if: github.event.pull_request.merged == true | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/github-script@v7 | ||
| with: |
| const body = context.payload.pull_request.body || ''; | ||
| const hasCloses = /(?:closes|fixes|resolves)\s+#\d+/i.test(body); | ||
| if (!hasCloses) { | ||
| core.setFailed('❌ Le body du PR doit contenir une référence "closes #XX".'); |
Comment on lines
+15
to
+17
| const source = context.payload.pull_request.head.ref; | ||
| if (source !== 'dev') { | ||
| core.setFailed(`❌ Les merges vers main sont uniquement autorisés depuis dev (branche source : ${source}).`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #19