we need some help
# help
m
we need some help
c
hey, what’s up?
m
we have some improvement but we are not getting the actual output
image.png
we got output as follows
image.png
- name: Setup Infracost uses: infracost/actions/setup@v2 # See https://github.com/infracost/actions/tree/master/setup for other inputs # If you can't use this action, see Docker images in https://infracost.io/cicd with: api-key: ${{ secrets.INFRACOST_API_KEY }} # Generate Infracost JSON file as the baseline. --format=json - name: Generate Infracost cost estimate baseline run: | current_env=$(basename ${{ inputs.WORKING_DIR }}) infracost breakdown --include-all-paths --show-skipped --path=${{ inputs.WORKING_DIR }} infracost breakdown --include-all-paths --show-skipped --format=json --out-file="/tmp/$current_env-base.json" --path=${{ inputs.WORKING_DIR }} - name: Generate Infracost diff run: | current_env=$(basename ${{ inputs.WORKING_DIR }}) infracost diff --include-all-paths --show-skipped --compare-to="/tmp/$current_env-base.json" --path=${{ inputs.WORKING_DIR }} infracost diff --include-all-paths --show-skipped --compare-to="/tmp/$current_env-base.json" --format=json --path=${{ inputs.WORKING_DIR }} --out-file="/tmp/$current_env-diff.json" infracost output --show-all-projects --fields=all --show-skipped --format=table --path="/tmp/$current_env-diff.json" - name: Post Infracost comment if: github.event_name == 'pull_request' run: | current_env=$(basename ${{ inputs.WORKING_DIR }}) infracost comment github --show-all-projects --show-skipped --path="/tmp/$current_env-diff.json" --repo=$GITHUB_REPOSITORY --github-token=${{ secrets.GIT_TOKEN }} --pull-request=${{github.event.pull_request.number}} --behavior=update
we are not getting we are not getting the All projects total
image.png
c
I believe the all projects has been removed in the latest version, we need to update that screenshot
Also, in your action you’re passing the same
--path=${{ inputs.WORKING_DIR }}
to the breakdown and diff commands, but you’re not doing a checkout between so there will never be any costs changes (because the tf code is the same)
m
ok. I will update that!!
updated!!
do you have any suggestions?
c
yeah that looks like it should work. any success?
m
@crooked-daybreak-55253 having another issue, when I added another env
image.png
image.png
c
Are you doing a matrix build? You’ll need a to save the output from the diff json for each build in the matrix, then pass them all to a single infracost comment (usually in a second gh actions job). There is an example matrix build in the infracost/actions repo.
m
yes, we are doing matrix build
Thank you!! I will try
HI @crooked-daybreak-55253 we are getting this outpu now
image.png
c
what does your action look like now?
and were you able to find the matrix build example in the infracost/actions repo?
m
Currently, we are getting two different comments for different env (dev/uat)
But we are not getting single comment for both env
This message contains interactive elements.
- name: Checkout base branch uses: actions/checkout@v3 with: ref: main # Generate Infracost JSON file as the baseline. --format=json - name: Generate Infracost cost estimate baseline run: | current_env=$(basename ${{ inputs.WORKING_DIR }}) infracost breakdown --include-all-paths --show-skipped --path=${{ inputs.WORKING_DIR }} infracost breakdown --include-all-paths --show-skipped --fields=all --format=json --out-file="/tmp/$current_env-base.json" --path=${{ inputs.WORKING_DIR }} - name: Checkout Current branch uses: actions/checkout@v3 - name: Generate Infracost diff run: | current_env=$(basename ${{ inputs.WORKING_DIR }}) mkdir -p tmp/${{ inputs.WORKING_DIR }} infracost diff --include-all-paths --show-skipped --compare-to="/tmp/$current_env-base.json" --path=${{ inputs.WORKING_DIR }} infracost diff --include-all-paths --show-skipped --compare-to="/tmp/$current_env-base.json" --format=json --path=${{ inputs.WORKING_DIR }} --out-file="tmp/${{ inputs.WORKING_DIR }}/infracost-diff.json" - uses: actions/upload-artifact@v3 if: github.event_name == 'pull_request' with: name: infracost-${{ inputs.ENV }} path: tmp/${{ inputs.WORKING_DIR }}/infracost-diff.json infracost-pr-comment: needs: ["infracost-estimates"] runs-on: ubuntu-latest steps: - uses: actions/download-artifact@v3 if: github.event_name == 'pull_request' with: name: infracost-${{ inputs.ENV }} path: tmp/${{ inputs.WORKING_DIR }} - name: Setup Infracost uses: infracost/actions/setup@v2 # See https://github.com/infracost/actions/tree/master/setup for other inputs # If you can't use this action, see Docker images in https://infracost.io/cicd with: api-key: ${{ secrets.INFRACOST_API_KEY }} - name: Post Infracost comment if: github.event_name == 'pull_request' working-directory: tmp/${{ inputs.WORKING_DIR }} run: | current_env=$(basename ${{ inputs.WORKING_DIR }}) ls -l infracost comment github --show-all-projects --show-skipped --path="./infracost-diff.json" --repo=$GITHUB_REPOSITORY --github-token=${{ secrets.GIT_TOKEN }} --pull-request=${{github.event.pull_request.number}} --behavior=new
c
In the infracost comment step you need to change ‘—path’ so it will pick up all the files you downloaded in the earlier step. So something like ‘--path="/tmp/infracost_*" ‘