-
Notifications
You must be signed in to change notification settings - Fork 109
On delete mode new comment always will be created #361
Description
Hello,
i have the situation when i change mode dynamically based on the result of another step, but on delete mode extra comment will be temporarily added all the time due to current logic.
I use this Action to add comment on PR in case if TFLinter finds some concerns based on exit code.
When TFLinter finds concern, the Action adds comment as it runs based on
- name: 'Set comment PR mode'
run: |
if [ "${{ steps.tflint.outputs.exitcode }}" != "0" ]; then
echo "pr_comment_mode=recreate" >> $GITHUB_ENV
else
echo "pr_comment_mode=delete" >> $GITHUB_ENV
fi
- name: 'Comment PR'
if: ${{ steps.tflint.outputs.exitcode != '0' || env.pr_comment_mode == 'delete'}}
uses: thollander/actions-comment-pull-request@v2
with:
message: |
## :microscope: TFLint validation
```shell
${{ steps.tflint.outputs.stdout || 'TFLint is running...' }}
```
pr_number: ${{ github.event.pull_request.number }}
mode: ${{ env.pr_comment_mode }}
comment_tag: "tflint_comment"
GITHUB_TOKEN: ${{ secrets.SOME_TOKEN }}
so, if there is any concerns it will be pr_comment_mode=recreate means comment will be added. Everything as expected.
When there is a new commit with changes, but still some concerns from TFLinter, comment will be recreated and Action works as expected.
But if all the TFLint concerns were fixed, then mentioned step sets pr_comment_mode=delete .
In this situation there is a small side effect as delete mode always creates comment. The thing is, there is a situation when it will be two PR comments from this Action, one created when it was TFLint concerns and the new extra short living comment as createComment function will be executed before post step which will remove both comments later.
It will be great if it can be avoided the creation of new intermediate PR comment when mode: delete in the situation I've described.
Maybe, it is kind of "new" mode (cleanup ?) when delete works just as delete, without creation of any comment before the deletion in the end during post step.