Skip to content

Commit 68eb180

Browse files
Add PR description check
1 parent f1a53d4 commit 68eb180

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

.github/workflows/validate_pr.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,27 @@ jobs:
2323
}
2424
2525
console.log('✅ PR title format is valid');
26+
27+
- name: Ensure PR Has a Nitro Companion
28+
uses: actions/github-script@v7
29+
with:
30+
script: |
31+
const prBody = context.payload.pull_request.body;
32+
33+
if (!prBody) {
34+
core.setFailed("The PR description is empty. Please ensure it contains the required link.");
35+
return;
36+
}
37+
38+
// The required regex pattern:
39+
// 1. Matches the literal string "pulled in by https://github.com/OffchainLabs/nitro/pull/"
40+
// 2. Requires one or more digits (\d+) for the pull request number (xxxx)
41+
// 3. The 'i' flag makes the entire match case-insensitive (e.g., "Pulled In By" is valid)
42+
const requiredRegex = /pulled in by https:\/\/github\.com\/OffchainLabs\/nitro\/pull\/\d+/i;
43+
44+
if (!requiredRegex.test(prBody)) {
45+
const errorMessage = "PR description validation failed. The description must contain a line matching the case-insensitive pattern: 'pulled in by https://github.com/OffchainLabs/nitro/pull/xxxx', where 'xxxx' is a number.";
46+
core.setFailed(errorMessage);
47+
} else {
48+
core.info("✅ PR description contains the required link.");
49+
}

0 commit comments

Comments
 (0)