Skip to content

Destination Branches

Destination Branches allows for the configuration of allowed source to destination branches for Terrateam operations. Default Terrateam behavior requires a pull request to have the default branch of the repository as the destination branch. This branch is usually named main or master.

Terrateam Configuration Terrateam behavior can be configured via a config.yml. This file is located in a directory named .terrateam at the root of your Terraform repository: .terrateam/config.yml.

See Configuration documentation for details.

Configuration

Top-level key: destination_branches

See Configuration Reference documentation for details.

KeyTypeDescription
branchStringThe branch that a pull request can be merged into.
source_branchesListThe branch name that can be merged.

Default configuration:

destination_branches:

The destination_branches directive specifies a list of allowed destination branches with an optional list of source branches. Each entry in the list can either be a string or an object.

The following three configurations are identical:

  • A string:
destination_branches:
  - main
  • An object only specifying the branch attribute:
destination_branches:
  - branch: main
  • An object, specifying source_branches using a glob to match all branches:
destination_branches:
  - branch: main
    source_branches: ['*']

Branch and Source Branches

branch

The branch attribute matches the branch that a pull request will be merged into.

source_branches

The source_branches attribute matches the branch name that will be merged.

Example Scenario

Using the destination_branches configuration above, consider the following pull request:

  • Source branch: hotfix/revert-ami
  • Destination branch: main

Terrateam would evaluate the pull request as follows:

  • The main branch matches against the branch attribute
  • The hotfix/revert-ami matches against the source_branches attribute

Matching Branches

The list of branches are evaluated in order, stopping at the first matching destination branch.

If the destination_branches configuration is specified, the repository’s default branch will not automatically be considered for evaluation.

The default branch must be in the list of branches to be an allowed destination branch.

Globs

Globs are supported in branch names and source branches using the * glob character.

Not Patterns

A ! can be placed before a source branch pattern to negate it.

This is only valid in the source_branches configuration.