Is my syntax for ignoring closed issues correct?

I use the peaceiris/actions-label-commenter Action for giving canned responses to issues based on the labels I assign/remove.
Now was my plan to add an if: github.event.state == 'open' to the job to only trigger it when the issue isn’t closed already to prevent unnesesary messages when someone labels the issue later on.

Issue (no pun intendet) is, that the Action seems to ignore pretty much any case, being it open or closed issues, which obviously is not what I want.

Here is the complete workflow:

name: Comment
    - labeled
    - unlabeled
    - labeled
    - unlabeled

    if: github.event.state == 'open'
    runs-on: ubuntu-latest
    - name: Checkout Code
      uses: actions/checkout@v2
        ref: master
    - name: Send Issue/Pull request comment
      uses: peaceiris/actions-label-commenter@v1.8.2
        github_token: ${{ secrets.GITHUB_TOKEN }}

According to the reference about issues does the JSON object contain the “state” key which contains either open, closed or all (What even does the last one indicate for a state?)

Should I update my Workflow to have a negated if for when issues are closed (if: github.event.state != 'closed') or is there something else I could do?

I believe it’s github.event.issue.state that you need.

Actions uses webhook payloads when triggered and the state is listed inside the issue object of those:

1 Like

Didn’t saw it being inside a issues object, so it makes sense now that it didn’t work.

1 Like