From 6e775ccf6c68bc89d3e9a5241f59d34d3b137d1f Mon Sep 17 00:00:00 2001 From: Yavor16 Date: Fri, 21 Mar 2025 14:37:53 +0200 Subject: [PATCH] Add github commit validation for missing Jira id --- .github/workflows/check-commit-message.yml | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/check-commit-message.yml diff --git a/.github/workflows/check-commit-message.yml b/.github/workflows/check-commit-message.yml new file mode 100644 index 0000000..5e283a3 --- /dev/null +++ b/.github/workflows/check-commit-message.yml @@ -0,0 +1,35 @@ +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: Check Commit Message + 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 containsText = false; + for (const commitData of commits.data) { + if (commitData.commit.message.includes("LMCROSSITXSADEPLOY")) { + containsText = true; + break; + } + } + + if (!containsText) { + core.setFailed("❌ Check Commit Message - Failed: At least one commit must contain the word 'LMCROSSITXSADEPLOY'."); + } \ No newline at end of file