Add github commit validation for missing Jira id #1
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
name: Check Commit Message for "LMCROSSITXSADEPLOY" | |
on: | |
pull_request: | |
types: [synchronize, opened] | |
jobs: | |
check_commit_message: | |
name: Check Commit Message | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get PR Commits | |
id: commits | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const prNumber = context.payload.pull_request.number; | |
const commits = await github.rest.pulls.listCommits({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: prNumber | |
}); | |
let containsTest = false; | |
for (const commit of commits.data) { | |
if (commit.commit.message.toLowerCase().includes("LMCROSSITXSADEPLOY")) { | |
containsTest = true; | |
break; | |
} | |
} | |
if (!containsTest) { | |
core.setFailed("❌ Check Commit Message - Failed: At least one commit must contain the word 'LMCROSSITXSADEPLOY'."); | |
} |