Skip to content
ํ”„๋กœ์ ํŠธ

์†Œ๊ฐœ

GitHub Action for Infracost. See cloud cost estimates for Terraform in pull requests. ๐Ÿ’ฐ๐Ÿ“‰ Love your cloud bill!

์‹œ์Šคํ…œ ๋ฐ ์ธํ”„๋ผ

์ด ์ˆ˜์น˜๋ฅผ ์ธก์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•

์ธก์ •๋œ ์Šคํƒ€ ์ฆ๊ฐ€

in 24h
0
in 7 days
+1
in 15 days
+1
in 1 month
๊ธฐ๋ก ์ˆ˜์ง‘ ์ค‘

์„œ๋กœ ๊ฒน์น˜๋Š” ๊ธฐ๊ฐ„์˜ ์ˆœ์ฆ๊ฐ€๋Ÿ‰์ด๋ฉฐ ์ผ๋ณ„ ํ•ฉ๊ณ„๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค. ์ธก์ •๊ฐ’์ด ์—†์œผ๋ฉด ๋น„์›Œ ๋‘ก๋‹ˆ๋‹ค. ์Šคํƒ€๋Š” ๊ด€์‹ฌ๋„๋ฅผ ๋‚˜ํƒ€๋‚ด๋ฉฐ ํ’ˆ์งˆ์„ ๋ณด์žฅํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

README.md

Original

Infracost GitHub Actions

This repository contains GitHub Actions for running Infracost in your CI pipeline to see cloud cost estimates for Terraform in pull requests.

We recommend using the Infracost GitHub App where possible as it's simpler to set up and faster to run. If your organization doesn't allow GitHub App installations, use the actions below as an alternative.

Actions

diff and scan

A streamlined alternative to chaining setup plus individual CLI steps. These actions integrate directly with the Infracost dashboard and handle the full PR lifecycle โ€” scanning on open/sync/reopen, updating status on close.

diff

Computes cost differences between two branches, posts a PR comment, and manages PR status in the Infracost dashboard. Handles the full PR lifecycle โ€” scans on open/sync/reopen, and marks the PR as merged or closed in the dashboard when it ends.

scan

Scans a single directory and uploads baseline cost data to the Infracost dashboard. Use this on pushes to your default branch to keep the dashboard up to date.

Example

on:
  pull_request:
    types: [opened, synchronize, closed, reopened]
  push:
    branches: [main]

permissions:
  contents: read
  pull-requests: write

jobs:
  diff:
    if: github.event_name == 'pull_request'
    runs-on: ubuntu-latest
    steps:
      # Checkout steps are skipped on closed PRs since diffing is not needed โ€”
      # the diff action below detects the closed event and updates the PR's
      # status in the Infracost dashboard (MERGED or CLOSED) without scanning.
      - uses: actions/checkout@v4
        if: github.event.action != 'closed'
        with:
          path: head

      - uses: actions/checkout@v4
        if: github.event.action != 'closed'
        with:
          ref: ${{ github.event.pull_request.base.ref }}
          path: base

      - uses: infracost/actions/diff@v5
        with:
          api-key: ${{ secrets.INFRACOST_API_KEY }}
          base-path: base
          head-path: head

  scan:
    if: github.event_name == 'push'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: infracost/actions/scan@v5
        with:
          api-key: ${{ secrets.INFRACOST_API_KEY }}
          path: .

See the diff README and scan README for the full list of inputs.

Both actions run the ghcr.io/infracost/ci image, so the runner needs Docker. For macOS runners, self-hosted runners without Docker, or checkouts outside $GITHUB_WORKSPACE, use the container: job or the binary install documented in infracost/ci instead.

setup (legacy)

Installs the Infracost CLI into your workflow. You then run infracost breakdown, infracost diff, and infracost comment as separate steps to generate cost estimates and post PR comments. New integrations should prefer diff and scan above.

Legacy setup action

Full example

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

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

- name: Generate Infracost cost estimate baseline
  run: |
    infracost breakdown --path=. \
                        --format=json \
                        --out-file=/tmp/infracost-base.json

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

- name: Generate Infracost diff
  run: |
    infracost diff --path=. \
                    --format=json \
                    --compare-to=/tmp/infracost-base.json \
                    --out-file=/tmp/infracost.json

- 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

See the setup README for the full list of inputs.

Contributing

We welcome contributions! Please start by opening a thread in GitHub Discussions to discuss your idea before submitting a PR.

Bugs and feedback

If you run into any issues or have feedback, please open a thread in GitHub Discussions. We'd love to hear from you!

License

Apache License 2.0

๊ด€๋ จ ํ”„๋กœ์ ํŠธ ์‚ดํŽด๋ณด๊ธฐ

๋ถˆ๋Ÿฌ์˜ค๋Š” ์ค‘โ€ฆ