Skip to content

Regression: Action can no longer be used for non-PR triggers #507

@birjj

Description

@birjj

Describe the bug

If the action is executed in a job that doesn't have an attached PR (e.g. one that's triggered on GitHub releases), then the action will fail with

...
Run # Post output.
gh: Not Found (HTTP 404)
Error: Process completed with exit code 1.

This is not particularly descriptive error (it doesn't say what it tried to do when it got a 404), but I believe it's caused by this line being executed:

Code executed
  # Check if the PR contains a bot comment with the same identifier.
  list_comments=$(gh api /repos/foobar/my-repo/issues/0/comments --header "$GH_API" --method GET --paginate)
Source code

TF-via-PR/action.yml

Lines 479 to 480 in 5b5ec65

# Check if the PR contains a bot comment with the same identifier.
list_comments=$(gh api /repos/${{ github.repository }}/issues/${{ steps.identifier.outputs.pr }}/comments --header "$GH_API" --method GET --paginate)

As you can see, it's trying to fetch comments for issue "0", which is likely where the 404 error comes from.

I believe this problem was introduced in #503, since it moved the list_comments=... line out of the if [[ "$create_comment" == "true" && "${{ steps.identifier.outputs.pr }}" != "0" ]]; then gate that it used to be behind.

To Reproduce

Run a workflow triggered on e.g.

on:
  release:
    types: [published]

Call the action there.

Expected behavior

The action should not attempt to read comments from issue 0.

Screenshots

Image

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions