|
| 1 | +# Merge Queue GitHub Action |
| 2 | + |
| 3 | +This repository provides a GitHub composite action that implements a **merge queue** with an optional hot‑fix fastlane. The queue is FIFO (first‑in, first‑out) and works on GitHub Free and private repositories. Merges are staged on a temporary branch before reaching your protected branch, ensuring that only tested code lands on `master`/`main`. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +* **FIFO merge queue** – Pull requests are merged in the order they were approved. |
| 8 | +* **Hot‑fix fastlane** – Pull requests whose branch name or title matches a configurable regex (for example `hotfix/`) bypass the queue. |
| 9 | +* **Auto‑update of stale branches** – Optionally update PR branches that have fallen behind your base by a specified number of commits. |
| 10 | +* **Shadow vs. live mode** – Shadow mode tests your configuration without merging; live mode performs actual merges. |
| 11 | +* **No additional services required** – Uses the built‑in `GITHUB_TOKEN` only; no enterprise features or external CI are required. |
| 12 | + |
| 13 | +## Installation |
| 14 | + |
| 15 | +Add the action to your workflow by referencing the tag in your repository. Make sure your repository’s **Settings → Branch protection** requires the custom status set in `status_context` (default `merge‑queue`) and disables **“Require branches to be up to date with base”**. |
| 16 | + |
| 17 | +### Example: shadow mode |
| 18 | + |
| 19 | +```yaml |
| 20 | +name: Merge Queue (shadow) |
| 21 | +on: |
| 22 | + pull_request: |
| 23 | + types: [opened, reopened, ready_for_review, synchronize, converted_to_draft, review_requested] |
| 24 | + schedule: |
| 25 | + - cron: "*/5 * * * *" |
| 26 | + workflow_dispatch: {} |
| 27 | + |
| 28 | +permissions: |
| 29 | + contents: write |
| 30 | + pull-requests: write |
| 31 | + statuses: write |
| 32 | + |
| 33 | +concurrency: |
| 34 | + group: merge-queue |
| 35 | + cancel-in-progress: true |
| 36 | + |
| 37 | +jobs: |
| 38 | + queue: |
| 39 | + runs-on: ubuntu-latest |
| 40 | + steps: |
| 41 | + - uses: igorjs/gh-actions-merge-queue@v1 |
| 42 | + with: |
| 43 | + base_branch: main |
| 44 | + mode: shadow |
| 45 | + merge_method: merge |
| 46 | + status_context: merge-queue |
| 47 | + behind_max_commits: "100" |
| 48 | + fastlane_matchers: "^(hotfix|critical|security)/,\\bhotfix\\b,^hotfix:" |
| 49 | +``` |
| 50 | +
|
| 51 | +### Example: live mode |
| 52 | +
|
| 53 | +To enable real merges, flip `mode` to `live` and adjust your branch protection accordingly. |
| 54 | + |
| 55 | +```yaml |
| 56 | + - uses: igorjs/gh-actions-merge-queue@v1 |
| 57 | + with: |
| 58 | + base_branch: main |
| 59 | + mode: live |
| 60 | + merge_method: merge |
| 61 | + status_context: merge-queue |
| 62 | + behind_max_commits: "100" |
| 63 | +``` |
| 64 | + |
| 65 | +## Inputs |
| 66 | + |
| 67 | +This action exposes a number of inputs to customise behaviour: |
| 68 | + |
| 69 | +* **token** – Optional, defaults to `GITHUB_TOKEN`. |
| 70 | +* **base_branch** – Base branch to merge into (default `master`). |
| 71 | +* **queue_branch** – Temporary branch used to stage the merge (default `merge‑queue/staging`). |
| 72 | +* **fastlane_branch** – Temporary branch for fastlane merges (default `merge‑queue/fastlane`). |
| 73 | +* **state_branch** – Branch that stores the FIFO queue file (default `merge‑queue/state`). |
| 74 | +* **queue_file** – Path to the queue JSON file inside the state branch (default `.github/merge‑queue‑queue.json`). |
| 75 | +* **status_context** – Commit status context; must be required in branch protection (default `merge‑queue`). |
| 76 | +* **mode** – `shadow` or `live` (default `shadow`). |
| 77 | +* **fastlane_matchers** – Comma‑separated regex patterns used to detect fastlane PRs. |
| 78 | +* **behind_max_commits** – Update PR branches if behind more than this number of commits (0 disables). |
| 79 | +* **merge_method** – `merge` (preserves the tested tree) or `squash`. |
| 80 | +* **clean_queue** – Whether to delete the temporary queue branches (default `true`). |
| 81 | + |
| 82 | +## Branch protection |
| 83 | + |
| 84 | +1. Protect your base branch (`master` or `main`). |
| 85 | +2. Require pull request reviews as you normally do. |
| 86 | +3. Add the status context specified in your workflow (default `merge‑queue`) as the only required status check. |
| 87 | +4. Turn **off** “Require branches to be up to date before merging.” |
| 88 | +5. Allow **merge commits** (recommended) or configure your merge method to squash. |
| 89 | + |
| 90 | +For more information on branch protection and security policies, see the GitHub documentation【162389469722289†L471-L485】. |
| 91 | + |
| 92 | +## License |
| 93 | + |
| 94 | +This project is licensed under the MIT License. The MIT License allows free use, modification, and distribution of the software, provided that the copyright notice and license text appear in all copies and substantial portions of the software【16404071374199†L4-L16】. |
| 95 | + |
| 96 | +## Code of Conduct |
| 97 | + |
| 98 | +Participation in this project is governed by a Code of Conduct that aims to create a welcoming and inclusive environment. The code is adapted from the Contributor Covenant v2.1 and outlines behaviours that foster a positive community and those that are unacceptable【426605577719396†L4-L27】. Please review it in [`CODE_OF_CONDUCT.md`](CODE_OF_CONDUCT.md). |
| 99 | + |
| 100 | +## Security |
| 101 | + |
| 102 | +To report a security vulnerability, please see [`SECURITY.md`](SECURITY.md) for instructions on responsible disclosure. |
0 commit comments