5
0
Fork 0
mirror of https://github.com/wagoid/commitlint-github-action.git synced 2025-11-07 08:06:54 +00:00

docs: update merge_group event support

This commit is contained in:
Yossi Saadi 2024-12-08 14:09:02 +02:00
parent 038b0eee2a
commit 1da85faa5a

View file

@ -24,6 +24,66 @@ jobs:
Alternatively, you can run on other event types such as `on: [push]`. In that case the action will lint the push event's commit(s) instead of linting commits from a pull request. You can also combine `push` and `pull_request` together in the same workflow.
### Using with GitHub Merge Queues
GitHub's [merge queue](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/managing-a-merge-queue) is a feature that allows you to queue pull requests for merging once they meet certain criteria. When using merge queues, you need to ensure that your workflows are set up to handle the merge_group event, which is triggered when pull requests are added to the merge queue.
#### Workflow Configuration
To use the commitlint-github-action with merge queues, you need to set up a workflow that listens to the merge_group event. Here's an example of how to configure your workflow:
```yaml
name: Lint Commit Messages in Merge Queue
on:
merge_group:
types:
- checks_requested
jobs:
commitlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.sha }}
- uses: wagoid/commitlint-github-action@v6
```
#### Important Note:
To ensure that the merge_group event triggers correctly, you need to have **at least one workflow that responds to the pull_request event** with a job named the same as the one in your merge_group workflow (**commitlint** in this example). This is necessary because the merge queue relies on the existence of status checks from the pull request context.
Here's a minimal pull_request workflow to satisfy this requirement:
```yaml
name: Placeholder Workflow for Merge Queue
on:
pull_request:
jobs:
commitlint:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
```
This workflow can also be a meaningful one that checks out the commits in your PR and runs other checks, but it must have a job named **commitlint**.
### Enabling Merge Queues in Your Repository
Before you can use merge queues, you need to enable the feature in your repository settings:
- Go to your repository's Settings > Branches.
- Under Branch protection rules, edit the rule for your target branch (e.g. master).
- Enable Require merge queue.
- Specify your new job (e.g. commitlint) and any other required status checks, that must pass before merging.
For more information on configuring merge queues, refer to the [GitHub documentation on managing a merge queue](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/managing-a-merge-queue).
## Inputs
You can supply these inputs to the `wagoid/commitlint-github-action@v6` step.