benchmarks.yml: Fix PR branch checkout when triggered by comment #1998
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR resolves an issue in our GitHub Actions workflow where the correct PR branch was not being checked out when the workflow was triggered by an 'issue_comment' event. Previously, the workflow was set up to handle the 'pull_request_target' event correctly, but it did not account for the different context provided by 'issue_comment'.
The fix involves adding conditional steps in the workflow to handle the 'issue_comment' event. When the workflow is triggered by an 'issue_comment', it now uses the GitHub API to extract the PR number from the comment context. This information is then used to retrieve the PR details, including the head branch and the repository name. With these details, the workflow can now correctly check out the PR branch associated with the issue comment. This ensures that our benchmarks and other PR-related checks run against the appropriate branch, regardless of the triggering event.
See #1994 (comment) and #1983 (comment).
Due to the issue arising with pull request from another fork and the workflow only being updated when merged into main, there is not convenient way to test this except for merging. So I propose we do that.