ci: improve commit lint enforcement #29
This file contains 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
#? should we comment in the PR? | |
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: | |
- name: git clone | |
uses: actions/checkout@v4 | |
- name: Setup | |
uses: ./.github/actions/setup | |
- name: Check commit messages | |
run: npx commitlint --from=origin/${{ github.base_ref }} | |
# Based on PR name | |
generate-commit-message: | |
name: Generate Commit Message | |
runs-on: ubuntu-latest | |
outputs: | |
commit_message: ${{ steps.generate-message.outputs.commit_message }} | |
steps: | |
- name: git clone | |
uses: actions/checkout@v4 | |
- name: Generate Title | |
id: generate-message | |
run: | | |
COMMIT_MESSAGE='${{ github.event.pull_request.title }}' | |
echo "Commit Message": '$COMMIT_MESSAGE' | |
echo "commit_message=$COMMIT_MESSAGE" >> $GITHUB_OUTPUT | |
echo "$COMMIT_MESSAGE" | |
validate-commit-message: | |
needs: [generate-commit-message] | |
name: Validate Commit Message | |
runs-on: ubuntu-latest | |
steps: | |
- name: git clone | |
uses: actions/checkout@v4 | |
- name: Setup | |
uses: ./.github/actions/setup | |
with: | |
full-checkout: false | |
- name: Validate Title | |
run: echo "${{needs.generate-commit-message.outputs.commit_message}}" | npx commitlint | |
generate-changelog: | |
needs: [generate-commit-message, validate-commit-message] | |
name: Generate Changelog | |
runs-on: ubuntu-latest | |
steps: | |
- name: git clone | |
uses: actions/checkout@v4 | |
- name: Setup | |
uses: ./.github/actions/setup | |
- name: Generate tmp branch | |
run: git checkout -b changelog | |
- name: Squash commits | |
run: | | |
git reset --soft $(git merge-base origin/${{ github.base_ref }} HEAD) | |
git commit -m "$COMMIT_MESSAGE" | |
git log | |
env: | |
COMMIT_MESSAGE: ${{needs.generate-commit-message.outputs.commit_message}} |