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

worried-agency-87622

12/12/2022, 1:52 PM
Hi. I'm getting the following error when running infracost via github actions: This is using the github infracost.yml template for a mono-repo and the workflow step example provided. Namely: - name: Infracost Actions uses: infracost/actions@v2.0.0 Any assistance greatly appreciated.
b

busy-agent-35515

12/12/2022, 2:01 PM
Hello! Can you post your workflow here? Have you have anything else in there apart from Infracost example?
Quick fix might be adding
shell: bash
to the steps, but I wonder what causes this issue
Copy code
- name: Setup Infracost
        uses: infracost/actions/setup@v2
You need just setup action to install CLI
w

worried-agency-87622

12/12/2022, 2:05 PM
Strangely it worked in our dev /stg/tst environments but not when pushed to main. Invoked as a job step in another workflow as follows: - name: Infracost Actions uses: infracost/actions@v2.0.0
b

busy-agent-35515

12/12/2022, 2:11 PM
Hm, interesting. The workflow is identical to the example 🙂
Can you try adding
shell: bash
to this step?
w

worried-agency-87622

12/12/2022, 2:17 PM
Would that be for this step. - name: Infracost Actions uses: infracost/actions@v2.0.0
b

busy-agent-35515

12/12/2022, 2:18 PM
Hm, I'm sorry, do I understand correctly that the code you showed is workflow 1, but you're trying invoke it from workflow 2?
I wonder if our default action needs to have a shell because it executes the CLI commands
See the line 38 of your log: it corresponds to this line in our action https://github.com/infracost/actions/blob/master/action.yml#L37
Using
uses: infracost/actions@v2.0.0
will call our default action
w

worried-agency-87622

12/12/2022, 2:22 PM
We have a workflow called pull-request-builder.yml that includes the code above, however there is also an infracost.yml as per the examples. So are you saying we do not need the infracost.yml file ? ALso when I added shell I got the following:
b

busy-agent-35515

12/12/2022, 2:26 PM
Thanks for the info. Seems like we should use a different syntax to reuse your infracost.yml workflow. Calling
infracost/actions
would use our's downloaded from GitHub
w

worried-agency-87622

12/12/2022, 2:27 PM
OK. Many thanks., I will give that a try. 👍
b

busy-agent-35515

12/12/2022, 2:27 PM
I'm sorry, I've never done this myself, but according to GitHub docs, this is called "reusable workflow" https://docs.github.com/en/actions/using-workflows/reusing-workflows#creating-a-reusable-workflow
w

worried-agency-87622

12/12/2022, 2:28 PM
Cheers. I will have a read up...
b

busy-agent-35515

12/12/2022, 2:28 PM
Hope this helps! Please ping me if you need more help 🙂
w

worried-agency-87622

12/12/2022, 2:28 PM
Will do. Many thanks
j

jolly-pilot-68525

12/12/2022, 4:43 PM
@worried-agency-87622 not sure if this is helpful, but here is a called workflow we use for Infracost: https://github.com/osinfra-io/github-terraform-gcp-called-workflows/blob/main/.github/workflows/infracost.yml and this is an example of how a caller would use it: https://github.com/osinfra-io/google-cloud-hierarchy/blob/main/.github/workflows/infracost.yml
b

busy-agent-35515

12/12/2022, 4:43 PM
Awesome! Thanks for the example Brett! 🙂
w

worried-agency-87622

12/12/2022, 4:44 PM
@jolly-pilot-68525 Excellent. Many thanks.
3 Views