fix: fail input drift for new integrations #122
This file contains hidden or 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
| name: "Conventional Commits" | |
| on: | |
| pull_request: | |
| types: | |
| - opened | |
| - edited | |
| - synchronize | |
| push: | |
| branches: [master, main] | |
| jobs: | |
| validate-pr-title: | |
| name: Validate PR title | |
| if: github.event_name == 'pull_request' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: amannn/action-semantic-pull-request@v6 | |
| id: lint_pr_title | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: marocchino/sticky-pull-request-comment@v2 | |
| if: always() && (steps.lint_pr_title.outputs.error_message != null) | |
| with: | |
| header: pr-title-lint-error | |
| message: | | |
| We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like your proposed title needs to be adjusted. | |
| Details: | |
| ``` | |
| ${{ steps.lint_pr_title.outputs.error_message }} | |
| ``` | |
| - if: ${{ steps.lint_pr_title.outputs.error_message == null }} | |
| uses: marocchino/sticky-pull-request-comment@v2 | |
| with: | |
| header: pr-title-lint-error | |
| delete: true | |
| validate-push-commits: | |
| name: Validate push commits | |
| if: github.event_name == 'push' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check commit messages | |
| run: | | |
| echo "Checking commits pushed to ${{ github.ref_name }}..." | |
| # Get commits in this push | |
| COMMITS=$(git log --format="%H %s" ${{ github.event.before }}..${{ github.event.after }} 2>/dev/null || git log --format="%H %s" -1) | |
| # Conventional commit pattern | |
| PATTERN="^[a-f0-9]+ (feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\(.+\))?(!)?: .+" | |
| FAILED=0 | |
| while IFS= read -r line; do | |
| if [[ ! "$line" =~ $PATTERN ]]; then | |
| echo "❌ Invalid commit: $line" | |
| FAILED=1 | |
| else | |
| echo "✅ Valid commit: $line" | |
| fi | |
| done <<< "$COMMITS" | |
| if [ $FAILED -eq 1 ]; then | |
| echo "" | |
| echo "Commit messages must follow Conventional Commits: https://www.conventionalcommits.org/" | |
| echo "Format: type(scope)?: description" | |
| echo "Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert" | |
| exit 1 | |
| fi |