How to limit Github workflow runs for certain users who raise PRs

I have a question about limiting the Github Action Workflow runs for certain users who raise a PR.

Let’s say UserA raises a PR, and UserB approves and merges the PR into the main branch. I was wondering if there was a way for Github actions to check which user raised the PR and then decides whether or not to run a workflow when it is merged into Main.

I know there is a context variable with in which I can use, but I am unsure if that checks UserB in the situation above, disregarding who raised the PR.

1 Like

I was able to find a solution to this. In this case, you can have the build run when a PR is closed, and within an if statemnt have the workflow check if the PR was closed due to a merge, and check who opened the PR.
That would look like this when a PR is merged into develop with the person who opened the PR being octobot:

    branches: [develop]
    types: [closed]

    if: github.event.pull_request.merged==true && github.event.pull_request.user.login!='octobot'