Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: test cicd #5

Closed
wants to merge 12 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: update cicd
mdepascale-reply committed Feb 22, 2024
commit 129756420f440e2234ccfd42923dff5c4dd0dbf0
45 changes: 28 additions & 17 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
@@ -14,44 +14,55 @@ jobs:
pull-requests: write

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

- name: Install tools using asdf
uses: asdf-vm/actions/[email protected]

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

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
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: Create Terraform plan on changed stacks
run: |
terramate run terraform init
terramate run terraform validate
terramate run terraform plan -out ./out.tfplan
- name: Setup Infracost
uses: infracost/actions/setup@v2
with:
api-key: ${{ secrets.INFRACOST_API_KEY }}

# Generate Infracost JSON file as the baseline.
- name: Generate Infracost cost estimate baseline
run: |
terramate run infracost breakdown \
--path ./out.tfplan \
--path=. \
--format=json \
--usage-file infracost-usage-medium.yml \
--out-file=./infracost-base.json
- name: Checkout PR branch
uses: actions/checkout@v4

# - name: Create Terraform plan on changed stacks
# run: |
# terramate run terraform init
# terramate run terraform validate
# terramate run terraform plan -out ./out.tfplan

- name: Generate Infracost diff
run: |
terramate run infracost diff \
--path=. \
--format=json \
--compare-to=./infracost-base.json \
--out-file=./infracost.json
- name: Post Infracost comment
run: |
terramate run infracost comment github \
--path=./infracost-base.json \
--path=./infracost.json \
--repo=$GITHUB_REPOSITORY \
--github-token=${{github.token}} \
--pull-request=${{github.event.pull_request.number}} \
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -7,4 +7,5 @@ plan.json
tfplan.binary

out.tfplan
infracost-base.json
infracost-base.json
infracost.json