Skip to content

Commit

Permalink
Change by terraform in repo workflow config, Add .github/workflows/in…
Browse files Browse the repository at this point in the history
…fracost.yaml
  • Loading branch information
viktoryathegreat committed Oct 13, 2023
1 parent f40944b commit a4520f6
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/infracost.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Infracost
on:
pull_request:
push:
branches: [main, master]
jobs:
terraform-validate:
runs-on: ubuntu-latest
permissions:
actions: write
contents: write
discussions: write
pull-requests: write
security-events: write
id-token: write
strategy:
matrix:
path:
- /

steps:
- name: Setup Infracost
uses: infracost/actions/setup@v2
with:
api-key: ${{secrets.INFRACOST_API_KEY}}

- name: Checkout base branch
uses: actions/checkout@v3
with:
ref: '${{ github.event.pull_request.base.ref }}'

- name: Generate Infracost cost estimate baseline
run: |
infracost breakdown --path=${{ matrix.path }} \
--format=json \
--out-file=/tmp/infracost-base.json
continue-on-error: true

- name: Checkout PR branch
uses: actions/checkout@v3

- name: Generate Infracost diff
run: |
infracost diff --path=${{ matrix.path }}\
--format=json \
--compare-to=/tmp/infracost-base.json \
--out-file=/tmp/infracost.json
continue-on-error: true

- name: Post Infracost comment
run: |
infracost comment github --path=/tmp/infracost.json \
--repo=$GITHUB_REPOSITORY \
--github-token=${{github.token}} \
--pull-request=${{github.event.pull_request.number}} \
--behavior=update
continue-on-error: true

0 comments on commit a4520f6

Please sign in to comment.