Skip to content

Commit

Permalink
ci: create a pr title and commit linter
Browse files Browse the repository at this point in the history
  • Loading branch information
dianjuar committed Oct 29, 2024
1 parent 95c5a50 commit 993e4b1
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 35 deletions.
37 changes: 2 additions & 35 deletions .github/workflows/pr.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: PR's
name: CI
on:
pull_request:
types: [opened, synchronize, reopened]
# types: [opened, synchronize, reopened]

env:
PR_NUMBER: ${{ github.event.pull_request.number }}
Expand All @@ -13,39 +13,6 @@ jobs:
pr-e2e-test:
uses: ./.github/workflows/e2e-test.yml

check-commit-lint:
name: Check commit message follows guidelines
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup

- name: Execute commitlint
run: npx commitlint --from=origin/${{ github.base_ref }}

- name: Get PR Title
run: "echo 'PR Title: ${{ github.event.pull_request.title }}'"

- name: Get commit messages
run: |
BODY=$(git log \
--abbrev-commit ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} \
--pretty=format:'* %s%n%n%b')
TITLE='${{ github.event.pull_request.title }}'
echo $TITLE
echo '---------'
echo $BODY
echo '---------'
echo "${TITLE}\n${BODY}"
echo '---------'
echo "${TITLE}\n${BODY}" > commit-message.txt
cat commit-message.txt
- name: Check commit message
run: cat commit-message.txt | npx commitlint

check-file-format:
name: Check files changes follow guidelines
runs-on: ubuntu-latest
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/enforce-semantic-commits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Enforce Semantic Commits

on:
pull_request:
types: [opened, edited, synchronize] #? reopened

jobs:
check-semantic-commits:
name: Check Semantic Commits
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup

- name: Fetch all commits for the PR
run: git fetch origin +refs/pull/${{ github.event.pull_request.number }}/merge

- name: Check commit messages
run: |
COMMIT_MESSAGES="$(git log --pretty=format:'%s' --abbrev-commit ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }})"
echo "$COMMIT_MESSAGES" | npx commitlint
# 'Check if the PR title is a valid semantic commit message'
check-pr-title:
name: Check PR Title
runs-on: ubuntu-latest
steps:
- name: Check PR Title
run: |
PR_TITLE='${{ github.event.pull_request.title }}'
echo "PR TITLE": '$PR_TITLE'
echo "$PR_TITLE" | npx commitlint

0 comments on commit 993e4b1

Please sign in to comment.