Skip to main content

GitHub Actions

Run Infracost in GitHub Actions to see cloud cost estimates and FinOps best practices in pull requests.

tip

We recommend using the GitHub App where possible — it's simpler to set up and faster to run. Use this integration if your organization doesn't allow GitHub App installations.

Quick start

  1. Install the Infracost CLI on your local machine.

  2. From inside your Terraform, CloudFormation, or CDK project directory, run:

    infracost ci setup --ci-pipeline

    This walks you through connecting your account, generating the GitHub Actions workflow file, and configuring the secrets your repo needs to post PR comments.

  3. Commit the generated workflow file and open a test pull request — see these steps for what to expect.

Migration guide

If you're running any version of the Infracost GitHub Action before 2.0.0, we recommend a clean migration rather than an in-place upgrade. We've distilled the lessons and best practices from years of running both the GitHub App and the previous CI/CD integrations into a much simpler approach — the workflow shape, action inputs, and required secrets have all changed as a result.

  1. Remove the existing Infracost GitHub Action from your repository — delete the workflow file (typically .github/workflows/infracost.yml) and any related steps in other workflows.

  2. From inside your Terraform, CloudFormation, or CDK project directory, run:

    infracost ci setup --ci-pipeline

    The --ci-pipeline flag generates the new pipeline configuration directly, skipping the interactive setup options you don't need on a re-install.

  3. Fetch a new token when prompted. Existing tokens from older versions are not compatible — let the setup flow generate a fresh one rather than reusing your old INFRACOST_API_KEY.

  4. Commit the new workflow file and open a test pull request to confirm the migration worked.