Hello there. I was about creating a workflow.yml f...
# help
o
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
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
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
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
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
Hm, looks right. Which can mean that
${{github.event.pull_request.number}}
is not defined
o
Keep in mind I had the error above when push to my branch
b
But do you have an open PR for this branch?
o
Yes
Hold on I think I know the issue
b
I just double checked on my own repo and the workflow picks up the number. I have
pull-request: write
permission btw
o
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
o
Thanks for your help Vadim! 😎
b
Of course! 🙂