|
| 1 | +name: Pull Request Lint Check |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: |
| 6 | + - opened |
| 7 | + - edited |
| 8 | + - synchronize |
| 9 | + - reopened |
| 10 | + |
| 11 | +jobs: |
| 12 | + title-lint: |
| 13 | + name: Validate title |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Checkout repository |
| 18 | + uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Load config |
| 21 | + id: load_config |
| 22 | + run: | |
| 23 | + # Load types and scopes directly from commitlint.config.mjs and set as environment variables |
| 24 | + node --experimental-modules -e " |
| 25 | + import('./commitlint.config.mjs').then(({ types, scopes }) => { |
| 26 | + // Write types and scopes as multiline environment variables |
| 27 | + console.log('TYPES<<EOF'); |
| 28 | + console.log(types.join('\n')); |
| 29 | + console.log('EOF'); |
| 30 | + |
| 31 | + console.log('SCOPES<<EOF'); |
| 32 | + console.log(scopes.join('\n')); |
| 33 | + console.log('EOF'); |
| 34 | + }); |
| 35 | + " >> $GITHUB_ENV |
| 36 | + echo "Done!" |
| 37 | +
|
| 38 | + - name: CI Check Title |
| 39 | + uses: amannn/action-semantic-pull-request@v5 |
| 40 | + env: |
| 41 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 42 | + with: |
| 43 | + wip: true |
| 44 | + # Configure which types are allowed (newline-delimited). |
| 45 | + # Default: https://github.com/commitizen/conventional-commit-types |
| 46 | + types: | |
| 47 | + ${{ env.TYPES }} |
| 48 | + scopes: | |
| 49 | + ${{ env.SCOPES }} |
| 50 | +
|
| 51 | + # Configure that a scope must always be provided. |
| 52 | + requireScope: true |
| 53 | + # Configure which scopes are disallowed in PR titles (newline-delimited). |
| 54 | + # For instance by setting the value below, `chore(release): ...` (lowercase) |
| 55 | + # and `ci(e2e,release): ...` (unknown scope) will be rejected. |
| 56 | + # These are regex patterns auto-wrapped in `^ $`. |
| 57 | + disallowScopes: | |
| 58 | + release |
| 59 | + [A-Z]+ |
| 60 | + # Configure additional validation for the subject based on a regex. |
| 61 | + # This example ensures the subject doesn't start with an uppercase character. |
| 62 | + subjectPattern: ^(?![A-Z]).+$ |
| 63 | + # If `subjectPattern` is configured, you can use this property to override |
| 64 | + # the default error message that is shown when the pattern doesn't match. |
| 65 | + # The variables `subject` and `title` can be used within the message. |
| 66 | + subjectPatternError: | |
| 67 | + The subject "{subject}" found in the pull request title "{title}" |
| 68 | + didn't match the configured pattern. Please ensure that the subject |
| 69 | + doesn't start with an uppercase character. |
| 70 | + # If the PR contains one of these newline-delimited labels, the |
| 71 | + # validation is skipped. If you want to rerun the validation when |
| 72 | + # labels change, you might want to use the `labeled` and `unlabeled` |
| 73 | + # event triggers in your workflow. |
| 74 | + ignoreLabels: | |
| 75 | + bot |
| 76 | + ignore-semantic-pull-request |
| 77 | + # If you're using a format for the PR title that differs from the traditional Conventional |
| 78 | + # Commits spec, you can use these options to customize the parsing of the type, scope and |
| 79 | + # subject. The `headerPattern` should contain a regex where the capturing groups in parentheses |
| 80 | + # correspond to the parts listed in `headerPatternCorrespondence`. |
| 81 | + # See: https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-commits-parser#headerpattern |
| 82 | + headerPattern: '^(\w*)(?:\(([\w$.\-*/ ]*)\))?: (.*)$' |
| 83 | + headerPatternCorrespondence: type, scope, subject |
0 commit comments