automerge
The automerge configuration can be used to automatically merge the pull request after all directories have been successfully applied.
Default Configuration
Section titled “Default Configuration”automerge: enabled: false delete_branch: false merge_strategy: auto require_explicit_apply: false retain_pr_title: false| Key | Type | Description |
|---|---|---|
| enabled | boolean | Specifies whether automerge is enabled. Default is false. |
| delete_branch | boolean | Specifies whether the branch should be deleted after the PR is merged. Default is false. |
| merge_strategy | string | The merge method to use when automerging. One of auto, merge, rebase, or squash. Default is auto. See Merge Strategy for details. |
| require_explicit_apply | boolean | Specifies whether an explicit “terrateam apply” is necessary for automerge functionality to be applied. Default is false. |
| retain_pr_title | boolean | When merging with squash, use the pull request title (followed by (#PR_NUMBER)) as the merge commit title instead of the default Terrateam Automerge #PR_NUMBER. Default is false. See Commit Title for details. |
Merge Strategy
Section titled “Merge Strategy”The merge_strategy key controls how Terrateam merges the pull request.
| Value | Description |
|---|---|
auto | On GitHub, attempts a merge commit first and falls back to squash if the repository does not allow merge commits. On GitLab, performs a standard (non-squash) merge. This is the default. |
merge | Creates a merge commit. |
rebase | Rebases the commits from the pull request onto the base branch. Supported on GitHub. |
squash | Squashes all commits in the pull request into a single commit. |
The selected strategy must be allowed by the repository’s merge settings. If the strategy is disabled at the repository level, the merge will fail (except for auto, which falls back on GitHub as described above).
Commit Title
Section titled “Commit Title”By default, when Terrateam squashes a pull request it sets the commit title to Terrateam Automerge #PR_NUMBER. Because every automerged commit then looks nearly identical, the main branch history can be hard to navigate.
Set retain_pr_title: true to use the original pull request title as the squash commit title instead. The pull request number is appended in parentheses, producing a title like My pull request title (#123). If the pull request title is unavailable, Terrateam falls back to the default Terrateam Automerge #PR_NUMBER.
This setting only affects squash merges (merge_strategy: squash, or auto when it falls back to squash). On GitLab it sets the squash commit message.
Examples
Section titled “Examples”Enable Automerge
Section titled “Enable Automerge”automerge: enabled: trueThis configuration will enable automerge, automatically merging the pull request after all directories have been successfully applied.
Enable Automerge and Delete Branch
Section titled “Enable Automerge and Delete Branch”automerge: enabled: true delete_branch: trueThis configuration will enable automerge and delete the source branch after a successful apply and git merge.
Enable Automerge with Squash
Section titled “Enable Automerge with Squash”automerge: enabled: true merge_strategy: squashThis configuration will enable automerge and squash all commits in the pull request into a single commit when merging.
Retain Pull Request Title in Squash Commit
Section titled “Retain Pull Request Title in Squash Commit”automerge: enabled: true merge_strategy: squash retain_pr_title: trueThis configuration will enable automerge with squash and use the pull request title (followed by (#PR_NUMBER)) as the squash commit title instead of the default Terrateam Automerge #PR_NUMBER.
Considerations
Section titled “Considerations”When enabling automerge, keep the following in mind:
- Automerge will only trigger after all directories in the pull request have been successfully applied.
- If any directory fails to apply, automerge will not be triggered.
- Automerge will respect any branch protection rules configured in your repository. If a pull request cannot be merged due to branch protection rules, automerge will not force the merge.
- If
delete_branchis enabled, the source branch will only be deleted if the merge is successful.