Skip to content

Support 'pull_request' event type#3

Closed
hainest wants to merge 1 commit into
Kitware:masterfrom
hainest:thaines/pr_event
Closed

Support 'pull_request' event type#3
hainest wants to merge 1 commit into
Kitware:masterfrom
hainest:thaines/pr_event

Conversation

@hainest

@hainest hainest commented Jun 29, 2026

Copy link
Copy Markdown

I found that I was getting a pull_request[1] event, but not a pull_request_target[2] when creating a pull request on a test repo. The docs for each say that they are both fired when a PR is opened, so I'm not sure why I wasn't seeing both.

Even though the 'pull_request' event uses the merge commit of the PR, github.event.pull_request.head.sha still refers to the last commit in the head branch of the PR.

There is a lot of discussion about the security[3] of pull_request_target. In particular, the workflow uses the GITHUB_TOKEN from the base repository which may be overly permissive. This update does not attempt to address those concerns.

[1] https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#pull_request
[2] https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#pull_request_target
[3] https://docs.github.com/en/actions/reference/security/securely-using-pull_request_target

I found that I was getting a pull_request[1] event, but not a
pull_request_target[2] when creating a pull request on a test repo. The
docs for each say that they are both fired when a PR is opened, so I'm
not sure why I wasn't seeing both.

Even though the 'pull_request' event uses the merge commit of the PR,
github.event.pull_request.head.sha still refers to the last commit in
the head branch of the PR.

There is a lot of discussion about the security[3] of
pull_request_target. In particular, the workflow uses the GITHUB_TOKEN
from the base repository which may be overly permissive. This update
does not attempt to address those concerns.

[1] https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#pull_request
[2] https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#pull_request_target
[3] https://docs.github.com/en/actions/reference/security/securely-using-pull_request_target
@vicentebolea

Copy link
Copy Markdown
Member

pull_request_target is needed since we want to have a GITHUB_TOKEN with perms to write commit status. pull_request types of event does not provides it.

The reason why pull_request_target does not trigger this in your PR is that pull_request_target will load the current version of master(main branch) CI files, no the PR version. This is why allows to have a permissive GITHUB_TOKEN since it naturally hedge against PR attacks.

@hainest

hainest commented Jul 23, 2026

Copy link
Copy Markdown
Author

Per-job permissions are preferred for using the action. See tools-integration/tools-sdk#17.

@hainest hainest closed this Jul 23, 2026
@hainest
hainest deleted the thaines/pr_event branch July 24, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants