Skip to content

Add GitHub workflows for PR validation and issue closure#20

Merged
OGR-67 merged 1 commit into
devfrom
19-ci-pr-validation-auto-close-issues-branch-protection
Mar 17, 2026
Merged

Add GitHub workflows for PR validation and issue closure#20
OGR-67 merged 1 commit into
devfrom
19-ci-pr-validation-auto-close-issues-branch-protection

Conversation

@OGR-67

@OGR-67 OGR-67 commented Mar 17, 2026

Copy link
Copy Markdown
Owner

Closes #19

Copilot AI review requested due to automatic review settings March 17, 2026 21:11
@OGR-67 OGR-67 merged commit 5bdc679 into dev Mar 17, 2026
3 checks passed
@OGR-67 OGR-67 deleted the 19-ci-pr-validation-auto-close-issues-branch-protection branch March 17, 2026 21:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 main to only those coming from a dev source branch.
  • Add a workflow to auto-close referenced issues when a PR is merged into dev, plus a PR template prompting authors to include closes #....

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}).`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants