Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull request description can include external PRs #38

Closed
sjohnr opened this issue May 2, 2022 · 0 comments · Fixed by #39
Closed

Pull request description can include external PRs #38

sjohnr opened this issue May 2, 2022 · 0 comments · Fixed by #39

Comments

@sjohnr
Copy link
Contributor

sjohnr commented May 2, 2022

Current behavior:

When building the status_string with something like "Failed: xyz's pull_request #X from Y to Z", the description sometimes includes pull requests from external repositories (forks) that reference a particular commit. This is very surprising and makes the notification look like it's coming from someone else's fork.

Here's an example:

Screen Shot 2022-05-02 at 12 35 52 PM

This was actually not a pull request at all, but a scheduled workflow. The latest commit included with the workflow run also appears in the pull requests of two separate forks that are using a pull request bot to synchronize commits with their fork, so GitHub includes them in the pull_requests field of the API. This also happens with pushes directly to a branch.

Suggested fix:

const pull_requests = (workflow_run.pull_requests as PullRequest[])
.map(
pull_request =>
`<${workflow_run.repository.html_url}/pull/${pull_request.number}|#${pull_request.number}> from \`${pull_request.head.ref}\` to \`${pull_request.base.ref}\``
)
.join(', ')

These lines could filter by the owner/repo of the current workflow run to ensure this PR data is for the current repo, not a fork. In our case, this should filter out all PRs attached to this workflow, and fall back to the description of the workflow run, not a PR.

sjohnr added a commit to sjohnr/slack-workflow-status that referenced this issue Jun 7, 2022
rsyvarth added a commit that referenced this issue Aug 19, 2022
Exclude PRs from external repos
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 a pull request may close this issue.

1 participant