feat: only run on changed stacks #67
Workflow file for this run
This file contains 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
name: Terramate with Infracost | |
on: | |
pull_request: | |
jobs: | |
preview: | |
name: Plan | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: write | |
pull-requests: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install tools using asdf | |
uses: asdf-vm/actions/[email protected] | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: eu-central-1 | |
- name: Setup Infracost | |
uses: infracost/actions/setup@v3 | |
with: | |
api-key: ${{ secrets.INFRACOST_API_KEY }} | |
- name: Create Terraform plan on changed stacks | |
run: | | |
terramate run --changed -- terraform init | |
terramate run --changed -- terraform validate | |
terramate run --changed -- terraform plan -out ./out.tfplan | |
- name: Generate Infracost cost estimate baseline | |
run: | | |
terramate run --changed -- infracost breakdown \ | |
--path ./out.tfplan \ | |
--format=json \ | |
--usage-file infracost-usage-medium.yml \ | |
--out-file=./infracost-base.json | |
- name: Post Infracost comment | |
run: | | |
terramate run --changed -- infracost comment github \ | |
--path=./infracost-base.json \ | |
--repo=$GITHUB_REPOSITORY \ | |
--github-token=${{github.token}} \ | |
--pull-request=${{github.event.pull_request.number}} \ | |
--behavior=new |