Finding a comment with pull request number

I’m currently trying to fix an Action that used to work, but is currently broken.

The problem boils down to github.event.number being empty. I previously used github.event.number to find the PR and a comment within it that I could update, but as of some point over the last month github.event.number became blank.

I have tried:

      - name: Dump Var
        run: echo "test ${{ github.event.number }}"

      # Looks for a comment with <!-- GH BOT --> somewhere in its body.
      - name: Find Comment
        uses: peter-evans/find-comment@v1
        if: success()
        id: fc
        with:
          issue-number: ${{ github.event.number }}
          body-includes: "<!-- GH BOT -->"

and

      - name: Dump Var
        run: echo "test ${{ github.event.pull_request.number }}"

      # Looks for a comment with <!-- GH BOT --> somewhere in its body.
      - name: Find Comment
        uses: peter-evans/find-comment@v1
        if: success()
        id: fc
        with:
          issue-number: ${{ github.event.pull_request.number }}
          body-includes: "<!-- GH BOT -->"

But “Find Comment” fails with:

Run peter-evans/find-comment@v1
  with:
    body-includes: <!-- GH BOT -->
    token: ***
    repository: creativiii/wordpress-react
    direction: first
  env:
    npm_config_cache: /home/runner/.npm
Error: Not Found

. “Dump Var” simply prints out:

Run echo "test "
test

Any ideas how I can get this to work?

What event are you triggering the workflow with, is it a pull_request or pull_request_comment event? And are you filtering on a specific event type when triggering them too?

This was the problem, the push event was overwriting the pull_request event, so the value was undefined.