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

orange-helicopter-53505

03/21/2023, 3:30 PM
Hello there. I was about creating a workflow.yml for gh action and had an issue. So I have multiple pipeline in 1 workflow (terrafrom fmt, checkov etc...), and all these pipelines can run
on: pull_request
but Infracost syntax runs only with this syntax
on: [pull_request]
. Is there any other option to fix this issue? Thank you in advance.
b

busy-agent-35515

03/21/2023, 3:33 PM
Hello! 🙂 Let me take a quick look at our actions and I'll get back to you.
Yes, our examples show
on: [pull_request]
, however this should be identical to
on: pull_request
according to GH workflows docs: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#using-multiple-events
Could you please elaborate a bit what you see? The steps with Infracost are not running? Or you don't receive a comment?
o

orange-helicopter-53505

03/21/2023, 3:39 PM
Error: either --commit or --pull-request is required
Error: Process completed with exit code 1.
From my understanding that Infracost is not recognizing the
on: pull_request
b

busy-agent-35515

03/21/2023, 3:42 PM
If you see this error, this means that the Infracost commands are running. Thus the trigger was correct
Can you show the exact command you're running for
infracost comment
?
This error tells that the command lacks required flags
o

orange-helicopter-53505

03/21/2023, 3:44 PM
Copy code
run: |
            infracost comment github --path=/tmp/infracost.json \
                                     --repo=$GITHUB_REPOSITORY \
                                     --github-token=${{github.token}} \
                                     --pull-request=${{github.event.pull_request.number}} \
                                     --behavior=update
b

busy-agent-35515

03/21/2023, 3:46 PM
Hm, looks right. Which can mean that
${{github.event.pull_request.number}}
is not defined
o

orange-helicopter-53505

03/21/2023, 3:47 PM
Keep in mind I had the error above when push to my branch
b

busy-agent-35515

03/21/2023, 3:48 PM
But do you have an open PR for this branch?
o

orange-helicopter-53505

03/21/2023, 3:48 PM
Yes
Hold on I think I know the issue
b

busy-agent-35515

03/21/2023, 3:53 PM
I just double checked on my own repo and the workflow picks up the number. I have
pull-request: write
permission btw
o

orange-helicopter-53505

03/21/2023, 3:58 PM
Thanks Vadim it was indeed the issue. Missing permission. Now Infracost is running on PR. Another question. I have also an event trigger on Push in workflow. And this will show an error with Infracost. Is there a way to exclude Infracost from Push?
b

busy-agent-35515

03/21/2023, 4:05 PM
o

orange-helicopter-53505

03/21/2023, 4:07 PM
Thanks for your help Vadim! 😎
b

busy-agent-35515

03/21/2023, 4:08 PM
Of course! 🙂