### GitHub Actions Workflow with Commitlint Source: https://github.com/wagoid/commitlint-github-action/blob/master/README.md Example GitHub Actions workflow demonstrating how to use the commitlint-github-action. It includes setup for Node.js and installs dependencies, setting NODE_PATH to include local node_modules. ```yaml name: Lint Commit Messages on: [pull_request] permissions: contents: read pull-requests: read jobs: commitlint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: '22' - run: npm install # Run the commitlint action, considering its own dependencies and yours as well 🚀 # `github.workspace` is the path to your repository. - uses: wagoid/commitlint-github-action@v6 env: NODE_PATH: ${{ github.workspace }}/node_modules ``` -------------------------------- ### Commitlint Text Output Example Source: https://github.com/wagoid/commitlint-github-action/blob/master/README.md Example of the text-based output from commitlint, showing errors and warnings for commit messages. ```text You have commit messages with errors ⧗ input: wrong message ✖ subject may not be empty [subject-empty] ✖ type may not be empty [type-empty] ✖ found 2 problems, 0 warnings ⓘ Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint ⧗ input: chore: my message ⚠ body must have leading blank line [body-leading-blank] ⚠ found 0 problems, 1 warnings ⓘ Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint ``` -------------------------------- ### Commitlint JSON Output Example Source: https://github.com/wagoid/commitlint-github-action/blob/master/README.md Example of the JSON output from commitlint, useful for programmatic access to commit analysis results in other GitHub Actions jobs. ```json [ { "hash": "cb0f846f13b490c2fd17bd5ed0b6f65ba9b86c75", "message": "wrong message", "valid": false, "errors": ["subject may not be empty", "type may not be empty"], "warnings": [], }, { "hash": "cb14483cbde23b61322ffb8d3fcdc87f514a3141", "message": "chore: my message\n\nsome context without leading blank line", "valid": true, "errors": [], "warnings": ["body must have leading blank line"], }, ] ``` -------------------------------- ### Load Custom Configs with `NODE_PATH` Source: https://context7.com/wagoid/commitlint-github-action/llms.txt Install custom commitlint configurations or plugins using `npm install` and expose the `node_modules` directory to the action via the `NODE_PATH` environment variable. This allows using external dependencies not bundled in the Docker image. ```yaml name: Lint Commit Messages on: [pull_request] permissions: contents: read pull-requests: read jobs: commitlint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: '22' - run: npm install # package.json must declare your custom config, e.g.: # "devDependencies": { "commitlint-config-myorg": "^1.0.0" } - uses: wagoid/commitlint-github-action@v6 env: NODE_PATH: ${{ github.workspace }}/node_modules with: configFile: commitlint.config.mjs # commitlint.config.mjs referencing the custom config: # export default { extends: ['commitlint-config-myorg'] } ``` -------------------------------- ### Use Pre-bundled `extends` Configurations Source: https://context7.com/wagoid/commitlint-github-action/llms.txt Leverage built-in shared configurations for common commit conventions like Conventional Commits, Angular, Lerna scopes, Jira ticket rules, and signed-off-by enforcement without additional installation. ```javascript // Conventional Commits (default fallback) export default { extends: ['@commitlint/config-conventional'] } ``` ```javascript // Angular commit conventions export default { extends: ['@commitlint/config-angular'] } ``` ```javascript // Lerna monorepo scopes (enforces package names as valid scopes) export default { extends: ['@commitlint/config-conventional', '@commitlint/config-lerna-scopes'], } // Valid: chore(second-package): update deps // Invalid: chore(wrong-scope): update deps ``` ```javascript // Jira ticket rules export default { plugins: ['commitlint-plugin-jira-rules'], extends: ['jira'], } // Valid: PROJ-123 feat: add login page // Invalid: ib-21212121212121: without jira ticket // → taskId must not be longer than 9 characters // → taskId must be uppercase case ``` ```javascript // Signed-off-by enforcement export default { extends: ['@commitlint/config-conventional'], rules: { 'signed-off-by': [2, 'always', 'Signed-off-by:'], }, } // Valid commit body must include: // Signed-off-by: John Doe ``` -------------------------------- ### Basic Usage of Commitlint GitHub Action Source: https://github.com/wagoid/commitlint-github-action/blob/master/README.md Set up a GitHub workflow to lint commit messages for pull requests. This example uses the action on pull_request events. ```yaml name: Lint Commit Messages on: [pull_request] permissions: contents: read pull-requests: read jobs: commitlint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: wagoid/commitlint-github-action@v6 ``` -------------------------------- ### Basic Pull Request Linting Source: https://context7.com/wagoid/commitlint-github-action/llms.txt Integrate this action into your workflow to lint commit messages on pull requests. No Node.js setup is required. ```yaml # .github/workflows/commitlint.yml name: Lint Commit Messages on: [pull_request] permissions: contents: read pull-requests: read jobs: commitlint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: wagoid/commitlint-github-action@v6 ``` -------------------------------- ### Specify Commitlint Config File Source: https://context7.com/wagoid/commitlint-github-action/llms.txt Use the `configFile` input to point to your custom commitlint configuration file. Ensure JavaScript files use the `.mjs` extension. If the file is not found, it defaults to `@commitlint/config-conventional`. ```yaml - uses: wagoid/commitlint-github-action@v6 with: configFile: commitlint.config.mjs # default; must be .mjs, not .js ``` ```javascript // commitlint.config.mjs export default { extends: ['@commitlint/config-conventional'], } ``` -------------------------------- ### Push Event Linting Source: https://context7.com/wagoid/commitlint-github-action/llms.txt Configure the action to run on `push` events to lint commits within the pushed range. Requires read permissions for contents. ```yaml name: Lint Commit Messages on Push on: [push] permissions: contents: read jobs: commitlint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: wagoid/commitlint-github-action@v6 ``` -------------------------------- ### Custom Help URL Source: https://context7.com/wagoid/commitlint-github-action/llms.txt Provide a custom URL via the `helpURL` input to direct users to your team's commit convention documentation in error messages. This input is overridden if `helpUrl` is set within the `commitlint.config.mjs` file. ```yaml - uses: wagoid/commitlint-github-action@v6 with: helpURL: 'https://wiki.example.com/commit-conventions' ``` ```javascript // commitlint.config.mjs – helpUrl takes priority over helpURL input export default { extends: ['@commitlint/config-conventional'], helpUrl: 'https://wiki.example.com/commit-conventions', } ``` -------------------------------- ### Provide GitHub API Token with `token` Source: https://context7.com/wagoid/commitlint-github-action/llms.txt Supply a Personal Access Token (PAT) to the `token` input for elevated permissions or when running in forks. Defaults to the automatic `github.token`. ```yaml - uses: wagoid/commitlint-github-action@v6 with: token: ${{ secrets.GITHUB_TOKEN }} ``` -------------------------------- ### Commitlint GitHub Action with Merge Queues Source: https://github.com/wagoid/commitlint-github-action/blob/master/README.md Configure a workflow to lint commit messages when using GitHub Merge Queues. This requires listening to the `merge_group` event and ensuring a pull_request workflow with a matching job name exists. ```yaml name: Lint Commit Messages in Merge Queue on: merge_group: types: - checks_requested jobs: commitlint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: ref: ${{ github.sha }} - uses: wagoid/commitlint-github-action@v6 ``` -------------------------------- ### Access Action Output `results` for Lint Data Source: https://context7.com/wagoid/commitlint-github-action/llms.txt The `results` output provides structured JSON data for each commit, including its hash, message, validity, errors, and warnings. This is useful for downstream jobs requiring machine-readable lint information. ```yaml jobs: commitlint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: wagoid/commitlint-github-action@v6 id: commitlint - name: Print lint results as JSON run: echo '${{ steps.commitlint.outputs.results }}' - name: Use results in another step run: | echo '${{ steps.commitlint.outputs.results }}' | \ jq '[.[] | select(.valid == false)] | length' ``` -------------------------------- ### Placeholder Workflow for Merge Queue Requirement Source: https://github.com/wagoid/commitlint-github-action/blob/master/README.md A minimal pull_request workflow required to satisfy merge queue event triggers. It must contain a job named 'commitlint' to ensure status checks are available in the pull request context. ```yaml name: Placeholder Workflow for Merge Queue on: pull_request: jobs: commitlint: runs-on: ubuntu-latest steps: - name: Checkout Repository uses: actions/checkout@v4 ``` -------------------------------- ### Suppress Failure on Errors Source: https://context7.com/wagoid/commitlint-github-action/llms.txt Configure `failOnErrors` to `false` to have the action log errors but exit with a success code. This is useful for advisory linting. ```yaml - uses: wagoid/commitlint-github-action@v6 with: failOnErrors: 'false' # Output on bad commit: # ✖ subject may not be empty [subject-empty] # ✖ type may not be empty [type-empty] # Fail on Errors is set to false: Passing despite errors ✅ ``` -------------------------------- ### Merge Queue Support Source: https://context7.com/wagoid/commitlint-github-action/llms.txt Use this configuration for `merge_group` events to lint the squashed commit message before merging. A corresponding `pull_request` job with the same name is required for GitHub status checks. ```yaml # Merge queue workflow name: Lint Commit Messages in Merge Queue on: merge_group: types: - checks_requested jobs: commitlint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: ref: ${{ github.sha }} - uses: wagoid/commitlint-github-action@v6 --- # Required companion pull_request workflow (same job name) name: Placeholder for Merge Queue on: [pull_request] jobs: commitlint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 ``` -------------------------------- ### Fail on Warnings Source: https://context7.com/wagoid/commitlint-github-action/llms.txt Set `failOnWarnings` to `true` to make the action fail when commit messages generate warnings, in addition to errors. The default is `false`. ```yaml - uses: wagoid/commitlint-github-action@v6 with: failOnWarnings: 'true' ``` -------------------------------- ### Limit Commits Linted with `commitDepth` Source: https://context7.com/wagoid/commitlint-github-action/llms.txt Use `commitDepth` to restrict linting to a specified number of the most recent commits. Non-integer values will result in all commits being linted. ```yaml - uses: wagoid/commitlint-github-action@v6 with: commitDepth: '5' # lint only the 5 most recent commits ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.