Skip to content

Commit d230d67

Browse files
authored
Feature: Improve the operation of CI tasks (#67)
* Feature: Improve the operation of CI tasks * Feature: Improve the operation of CI tasks
1 parent a647db7 commit d230d67

File tree

4 files changed

+68
-108
lines changed

4 files changed

+68
-108
lines changed

.github/scripts/trigger-CI.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ COMMIT_ID=$1
1111
SECURITY=$2
1212
REPO_URL="https://github.com/${GITHUB_REPOSITORY}.git"
1313
PROJECT_ID="3567319"
14-
BRANCH_REF="github-intern"
14+
BRANCH_REF="master"
1515
CANCEL_IN_PROGRESS="true"
1616
PIPELINE_ID="42305"
1717
GITHUB_COMMIT_ID="${COMMIT_ID}"

.github/scripts/trigger-merge.sh

Lines changed: 0 additions & 60 deletions
This file was deleted.

.github/workflows/merge-request-trigger.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: PR Issue Link Check
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, synchronize]
6+
7+
jobs:
8+
check-issue-link:
9+
runs-on: ubuntu-latest
10+
if: github.event.action == 'opened' || github.event.action == 'edited'
11+
12+
steps:
13+
- name: Check if PR references an issue
14+
uses: actions/github-script@v7
15+
with:
16+
github-token: ${{ secrets.GITHUB_TOKEN }}
17+
script: |
18+
const { data: pr } = await github.rest.pulls.get({
19+
owner: context.repo.owner,
20+
repo: context.repo.repo,
21+
pull_number: context.issue.number
22+
});
23+
24+
// Check PR body for issue references
25+
const prBody = pr.body || '';
26+
const issueRegex = /(fixes|fix|closes|close|resolves|resolve|refs|references)\s+#(\d+)/gi;
27+
const hasIssueReference = issueRegex.test(prBody);
28+
29+
// Check PR title for issue references
30+
const prTitle = pr.title || '';
31+
const titleIssueRegex = /#\d+/g;
32+
const hasTitleIssueReference = titleIssueRegex.test(prTitle);
33+
34+
if (!hasIssueReference && !hasTitleIssueReference) {
35+
// Create the comment body
36+
const commentBody = [
37+
'⚠️ **PR Must Reference an Issue**',
38+
'',
39+
"This pull request doesn't reference any issue. Please link your PR to an existing issue by:",
40+
'',
41+
'1. Adding one of the following keywords in your PR description followed by the issue number:',
42+
' - fixes #123',
43+
' - closes #123',
44+
' - resolves #123',
45+
' - refs #123',
46+
' - references #123',
47+
'',
48+
'2. Or including the issue number in the PR title like:',
49+
' - [FEATURE] Add new feature #123',
50+
' - [BUG] Fix critical bug #123',
51+
'',
52+
`If no issue exists for this change, please [create an issue](https://github.com/${context.repo.owner}/${context.repo.repo}/issues/new) first to describe the problem or feature request.`
53+
].join('\n');
54+
55+
// Add comment asking to link an issue
56+
await github.rest.issues.createComment({
57+
owner: context.repo.owner,
58+
repo: context.repo.repo,
59+
issue_number: context.issue.number,
60+
body: commentBody
61+
});
62+
63+
// Fail the check
64+
core.setFailed('PR must reference an issue');
65+
} else {
66+
console.log('✅ PR properly references an issue');
67+
}

0 commit comments

Comments
 (0)