Skip to content

Commit

Permalink
ci(github-actions): add stricter head commit check for release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee-W authored and phanikumv committed Jul 25, 2023
1 parent 0527bce commit 62fbea7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/scripts/validate_release_commit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import re
import sys

if __name__ == "__main__":
pattern = r"^Release \d{1,}\.\d{1,}\.\d{1,}$"
if len(sys.argv) == 2:
commit_message = sys.argv[1]
if not re.fullmatch(pattern, commit_message):
print(f"{commit_message} does not match '{pattern}'")
sys.exit(1)
else:
print(f"{commit_message} matches '{pattern}'")
else:
raise ValueError("One positional argument 'commit message' is required")
6 changes: 6 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Check head commit message
env:
head_commit_title: ${{ github.event.head_commit.message }}
run: |
python ./.github/scripts/validate_release_commit.py "$head_commit_title"
- name: Install commitizen
run: |
pip3 install commitizen
Expand Down

0 comments on commit 62fbea7

Please sign in to comment.