Skip to content

ci: improve commit lint enforcement #22

ci: improve commit lint enforcement

ci: improve commit lint enforcement #22

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
generate-commit-message:
# Based on PR name
name: Generate Commit Message
runs-on: ubuntu-latest
outputs:
commit_message: ${{ steps.generate-title.outputs.commit_message }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- name: Generate Title
id: generate-title
run: |
COMMIT_MESSAGE='${{ github.event.pull_request.title }}'
echo "Commit Message": '$COMMIT_MESSAGE'
echo "commit_message=$COMMIT_MESSAGE" >> $GITHUB_OUTPUT
generate-changelog:
needs: [generate-commit-message]
name: Generate Changelog #? should we comment in the PR?
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ./.github/actions/setup
- name: Generate tmp branch
run: git checkout -b changelog
- run: echo "$COMMIT_MESSAGE"
env:
COMMIT_MESSAGE: ${{needs.generate-commit-message.outputs.commit_message}}
# - name: Squash commits
# run: |
# echo "${{steps.check-title.outputs.pr_title}}"
# git fetch
# git reset --soft $(git merge-base origin/main HEAD)
# git commit -m "${{ steps.check-title.outputs.pr_title }}"
# git log