Last active
July 16, 2026 17:12
-
-
Save tbeyer567/15b5ee9afac72a9245d11f26e1f15aa3 to your computer and use it in GitHub Desktop.
gitlab ci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| terraform_plan: | |
| stage: plan | |
| image: hashicorp/terraform:1.15 | |
| variables: | |
| TF_TOKEN_app_terraform_io: $TF_CLOUD_TOKEN # Set this in GitLab CI/CD Variables | |
| before_script: | |
| - terraform --version | |
| - terraform init | |
| script: | |
| - terraform plan -detailed-exitcode -out=plan.tfplan || true | |
| artifacts: | |
| reports: | |
| terraform: plan.tfplan # Nice Terraform widget in GitLab UI | |
| paths: | |
| - plan.tfplan | |
| expire_in: 7 days | |
| rules: | |
| # Run on pushes to any branch except main (when Terraform files change) | |
| - if: $CI_COMMIT_BRANCH != "main" && $CI_PIPELINE_SOURCE == "push" | |
| changes: | |
| - "**/*.tf" | |
| - "**/*.tfvars" | |
| - ".gitlab-ci.yml" | |
| when: always | |
| # Always run on Merge Requests | |
| - if: $CI_MERGE_REQUEST_IID | |
| when: always |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment