From b6205aa4674f1a27f00c89b349b5d2a5fcc35fc4 Mon Sep 17 00:00:00 2001 From: Tim McFadden <52185+tim775@users.noreply.github.com> Date: Tue, 30 Nov 2021 12:41:29 -0500 Subject: [PATCH 1/4] feat: Add top-level action (#32) * feat: Add top-level action * fix: Remove working-directory param * Update action.yml Co-authored-by: Alistair Scott * feat: Add path input * fix: kebab case * Update action.yml Co-authored-by: Ali Khajeh-Hosseini * Update action.yml * fix: Add required shell * Update action.yml * fix: Require api-key input Co-authored-by: Alistair Scott Co-authored-by: Ali Khajeh-Hosseini --- action.yml | 47 ++++++++++++++++++++++++++++++++++++++++++++++ comment/action.yml | 2 +- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 action.yml diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..ec75086 --- /dev/null +++ b/action.yml @@ -0,0 +1,47 @@ +# This is a placeholder action, see https://github.com/infracost/actions/ for the Infracost actions and examples of how to use them. +name: Infracost +description: See cloud cost estimates for Terraform in pull requests. + +author: infracost +branding: + icon: trending-up + color: yellow +inputs: + api-key: + description: Your Infracost API key. It can be retrieved by running `infracost configure get api_key`. If you don't have one, download Infracost (https://www.infracost.io/docs/#quick-start) and run `infracost register` to get a free API key. + required: true + path: + description: The path that will be passed to `infracost breakdown`. This may be a path to a Terraform plan JSON or a Terraform project. Project support requires Terraform to have been installed with hashicorp/setup-terraform@v1. + required: true + behavior: + description: The behavior to use when posting cost estimate comments. Must be one of 'update' | 'delete-and-new' | 'hide-and-new' | 'new'. + required: false + default: update +runs: + using: "composite" + steps: + # Install the Infracost CLI, see https://github.com/infracost/actions/tree/master/setup + # for other inputs such as version, and pricing-api-endpoint (for self-hosted users). + - name: Setup Infracost + uses: infracost/actions/setup@v1 + with: + api-key: ${{ inputs.api-key }} + + # Generate Infracost JSON output, the following docs might be useful: + # Multi-project/workspaces: https://www.infracost.io/docs/multi_project/config_file + # Combine Infracost JSON files: https://www.infracost.io/docs/multi_project/report + - name: Generate Infracost JSON + shell: bash + run: infracost breakdown --path ${{ inputs.path }} --format json --out-file /tmp/infracost.json + # Env vars can be set using the usual GitHub Actions syntax + # env: + # MY_ENV: ${{ secrets.MY_ENV }} + + # See https://github.com/infracost/actions/tree/master/comment + # for other inputs such as target-type. + - name: Post Infracost comment + uses: infracost/actions/comment@v1 + with: + path: /tmp/infracost.json + # Choose the commenting behavior, 'update' is a good default: + behavior: ${{ inputs.behavior }} diff --git a/comment/action.yml b/comment/action.yml index 4b6d9cd..f19a3b1 100644 --- a/comment/action.yml +++ b/comment/action.yml @@ -5,7 +5,7 @@ inputs: description: The path to the `infracost breakdown` JSON that will be passed to `infracost output`. For multiple paths, pass a glob pattern (e.g. "infracost_*.json", glob needs quotes) or a JSON array of paths. required: true behavior: - description: The behavior to use when posting cost estimate comments. Must be one of 'update' | 'delete_and_new' | 'hide-and-new' | 'new'. + description: The behavior to use when posting cost estimate comments. Must be one of 'update' | 'delete-and-new' | 'hide-and-new' | 'new'. required: false default: update target-type: From dc9f4f16929775a70b3b5164c007f46695f53f37 Mon Sep 17 00:00:00 2001 From: Tim McFadden <52185+tim775@users.noreply.github.com> Date: Tue, 30 Nov 2021 12:54:23 -0500 Subject: [PATCH 2/4] Update action.yml --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index ec75086..3e6f6e1 100644 --- a/action.yml +++ b/action.yml @@ -1,5 +1,5 @@ # This is a placeholder action, see https://github.com/infracost/actions/ for the Infracost actions and examples of how to use them. -name: Infracost +name: Infracost Actions description: See cloud cost estimates for Terraform in pull requests. author: infracost From f2cc9103f425a0a356326d56ee970bf117759783 Mon Sep 17 00:00:00 2001 From: Ali Khajeh-Hosseini Date: Wed, 1 Dec 2021 17:15:18 +0300 Subject: [PATCH 3/4] Update CONTRIBUTING.md --- CONTRIBUTING.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6c50ede..b5fe0da 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -72,3 +72,11 @@ export GITHUB_TOKEN= npm run examples:update_golden ``` +# Releases + +One of the Infracost team members should follow these steps to release this repo: +1. `git checkout master && git pull origin master` +2. `git tag vX.Y.Z && git push origin vX.Y.Z` (following semantic versioning) +3. `git tag -f v1 && git push origin v1 -f` (assuming the new release is backward compatible with v1) +4. Confirm that the [repo tags](https://github.com/infracost/actions/tags) show matching git SHAs for vX.Y.X and v1. +5. Create a release for v.X.Y.Z and publish it in the [GitHub Marketplace](https://github.com/marketplace/actions/infracost-actions). From 62e18ed6564110a47437c1603cb669d9bd4683e1 Mon Sep 17 00:00:00 2001 From: Kasper Jacobsen Date: Wed, 1 Dec 2021 17:37:23 +0100 Subject: [PATCH 4/4] fix: broken link to slack example (#33) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ddca0da..0f70d95 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ The [examples](examples) directory demonstrates how these actions can be used in - [Multi-Terraform workspace](examples/multi-terraform-workspace): multiple Terraform workspaces using the Infracost [config file](https://www.infracost.io/docs/multi_project/config_file) - [Private Terraform module](examples/private-terraform-module): a Terraform project using a private Terraform module - [Thresholds](examples/thresholds): only post a comment when cost thresholds are exceeded - - [Slack](slack): send cost estimates to Slack + - [Slack](examples/slack): send cost estimates to Slack ## Actions