Skip to content

Commit c3ddd4c

Browse files
authored
Merge pull request #227 from cloudfoundry/add-commit-message-validation
Add github commit validation for missing Jira id
2 parents 3cd9908 + 6e775cc commit c3ddd4c

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Check Commit Message for "LMCROSSITXSADEPLOY"
2+
3+
on:
4+
pull_request:
5+
types: [synchronize, opened]
6+
7+
jobs:
8+
check_commit_message:
9+
name: Check Commit Message
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Check Commit Message
14+
id: commits
15+
uses: actions/github-script@v6
16+
with:
17+
script: |
18+
const prNumber = context.payload.pull_request.number;
19+
const commits = await github.rest.pulls.listCommits({
20+
owner: context.repo.owner,
21+
repo: context.repo.repo,
22+
pull_number: prNumber
23+
});
24+
25+
let containsText = false;
26+
for (const commitData of commits.data) {
27+
if (commitData.commit.message.includes("LMCROSSITXSADEPLOY")) {
28+
containsText = true;
29+
break;
30+
}
31+
}
32+
33+
if (!containsText) {
34+
core.setFailed("❌ Check Commit Message - Failed: At least one commit must contain the word 'LMCROSSITXSADEPLOY'.");
35+
}

0 commit comments

Comments
 (0)