Skip to content

when_modified

The when_modified configuration allows you to configure autoplan and autoapply operations based on pull request file changes. This enables you to automatically trigger plan and apply operations when specific files are modified in your repository.

Default Configuration

when_modified:
file_patterns: ["**/*.tf", "**/*.tfvars"]
autoplan: true
autoplan_draft_pr: true
autoapply: false

Keys

KeyTypeDescription
file_patternsListList of file globs to identify changes in a directory. Always relative to the root of the repository. Prefix with ! to exclude a file glob. Default is ["**/*.tf", "**/*.tfvars"].
autoplanBooleanAutomatically run a plan operation on a new pull request or an update on an existing one. Default is true.
autoplan_draft_prBooleanAutomatically run a plan operation on a new draft pull request or an update on an existing one. Default is true.
autoapplyBooleanAutomatically run an apply operation after merging a pull request. Default is false.

File Patterns

The file_patterns key specifies a list of file globs that identify changes in a directory. These patterns are relative to the root of the repository.

Auto-Plan

The autoplan key enables or disables automatic plan operations on new pull requests or updates to existing ones.

Auto-Plan Draft Pull Request

The autoplan_draft_pr key enables or disables automatic plan operations on new draft pull requests or updates to existing ones.

Auto-Apply

The autoapply key enables or disables automatic apply operations after merging a pull request.

Examples

Auto-Plan on Terraform File Changes

when_modified:
file_patterns: ["**/*.tf"]
autoplan: true
autoplan_draft_pr: false
autoapply: false

This configuration triggers a plan operation automatically when any .tf file in the repository is modified. It does not trigger plans on draft pull requests and does not automatically apply changes after merging.

Auto-Plan and Auto-Apply on Terraform and tfvars File Changes

when_modified:
file_patterns: ["**/*.tf", "**/*.tfvars"]
autoplan: true
autoplan_draft_pr: true
autoapply: true

This configuration triggers plan operations automatically on changes to .tf or .tfvars files, including draft pull requests. It also automatically applies changes after merging and creates a status check for pending applies.

Exclude Certain Files from Triggering Auto-Plan

when_modified:
file_patterns: ["**/*.tf", "!**/modules/**/*.tf"]
autoplan: true
autoplan_draft_pr: true
autoapply: false

This configuration triggers plan operations automatically on changes to .tf files, including draft pull requests, but excludes .tf files in the modules directory and its subdirectories.

We use cookies and similar technologies to provide certain features, enhance the user experience and deliver content that is relevant to your interests. Depending on their purpose, analysis and marketing cookies may be used in addition to technically necessary cookies. By clicking on "Agree and continue", you declare your consent to the use of the aforementioned cookies. Here you can make detailed settings or revoke your consent (in part if necessary) with effect for the future. For further information, please refer to our Privacy Policy .