Only posting comment if condition is met
EdwinFairchild opened this issue · comments
Hey peter,
I have a question , if I wanted to only post the comment on the return value of a script
for example if the script returns a non-zero value post the comment.
I am new to github actions so there might be something I am not doing properly
I am trying to assign the return value of the script to an environment variable
and then checking that in the if statement of your example code.
- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: This comment was written by a bot!
- name: Create comment
if: steps.fc.outputs.comment-id == '' && env.failedNum != 0
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
This comment was written by a bot!
reactions: rocket
- name: Update comment
if: steps.fc.outputs.comment-id != '' && env.failedNum != 0
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
body: |
This comment has been updated!
reactions: hooray`
I've never seen env.
variables used in expressions like that before. Does that work? Perhaps it's a new feature that I don't know about. Or maybe that's not possible, which is why it's not working. 😄
You could try using step outputs instead of env.
variables. There should be plenty of examples of doing this in GitHub's own documentation.
yeah i have no clue what I was doing here. I fixed my issue though, thanks.