https://infracost.io logo
#help
Title
# help
m

melodic-ocean-16661

07/04/2023, 5:46 PM
we need some help
c

crooked-daybreak-55253

07/04/2023, 5:47 PM
hey, what’s up?
m

melodic-ocean-16661

07/04/2023, 5:47 PM
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

crooked-daybreak-55253

07/04/2023, 5:50 PM
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

melodic-ocean-16661

07/04/2023, 5:59 PM
ok. I will update that!!
updated!!
do you have any suggestions?
c

crooked-daybreak-55253

07/04/2023, 6:57 PM
yeah that looks like it should work. any success?
m

melodic-ocean-16661

07/04/2023, 9:21 PM
@crooked-daybreak-55253 having another issue, when I added another env
image.png
image.png
c

crooked-daybreak-55253

07/05/2023, 12:37 AM
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

melodic-ocean-16661

07/05/2023, 2:41 PM
yes, we are doing matrix build
Thank you!! I will try
HI @crooked-daybreak-55253 we are getting this outpu now
image.png
c

crooked-daybreak-55253

07/05/2023, 8:14 PM
what does your action look like now?
and were you able to find the matrix build example in the infracost/actions repo?
m

melodic-ocean-16661

07/05/2023, 9:08 PM
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

crooked-daybreak-55253

07/05/2023, 9:56 PM
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_*" ‘
2 Views