Get Bots user id from Github Action?

Hey Y’all,
I have a need to get the user.id of the bot that is running within a github action. I analyzed all the values and api requests trying to find it but couldn’t find it for the life of me.

My goal is that within https://github.com/bradennapier/eslint-plus-action the user can elect to have the bot post comments to the PR with summaries of the eslint results. If there are previous results then it deletes those comments so it doesnt spam the issue directly.

Right now I am getting the response of posting a new comment then using the user.id returned in that requests to search and delete any other comments. However, I also sometimes need to just delete that comment and not post a new one so right now I am posting a fake comment then deleting it immediately which is clearly not ideal.

So I have a workaround I am already using for this, but it isn’t pretty. I’m sure I am just missing something simple!

Basically right now the only way I have found to do it is something like:

const commentResult = await client.issues.createComment({
        owner: OWNER,
        repo: REPO,
        issue_number: data.prID,
        body: 'Some Body Here',
      });
      const userId = commentResult.data.user.id;

      const userIssues = issues.data.filter(
        (issue) => issue.user.id === userId,
      );

      if (userIssues.length > 0) {
        await Promise.all(
          userIssues.map((issue) =>
            client.issues.deleteComment({
              owner: OWNER,
              repo: REPO,
              comment_id: issue.id,
            }),
          ),
        );
      }

@bradennapier,

You can get the id of the user from the github context via the expression “github.event.comment.user.id”.

When a workflow run is triggered by the created activity type of the issue_comment event, you can use “github.event.comment.user.id” to get the id of the user who posts the new comment on the issue or pull request.

on:
  issue_comment:
    types: [created]

Use the API “List issue comments”, you can get the list of the comments on a specified issue or pull request. Then you can use the user id you fetch above to filter the comments from the Response of the API.

After that, use the API “Delete an issue comment” to delete the specified comments.

This is on a Pull Request and I need the id of the bot that is running not the user that commented.

So when there is a PR - the bot comments on that PR with the result of eslint and needs to know its own ID before making that comment.

AKA need a way to get the user id of the “authenticated user” that would post a comment if the postComment request is made.

As the original post shows I am already using list issue comments and deleting an issue comment. My problem is it is impossible to know the ID that I will be posting the comment as until I actually make a comment which in some cases I don’t want to have to do.