From 9ffddbac1f4647dd77353ba3b120db91fea72d98 Mon Sep 17 00:00:00 2001 From: Nestor Soriano Date: Thu, 29 Jul 2021 16:47:27 +0200 Subject: [PATCH] Use 'pull_request_target' in the automatic milestoning action The original event used, 'pull_request', runs in the context of the pull request. In the case of pull requests created from forks this means that a read-only GitHub token is used for API calls, and thus the call used to assign the milestone fails. The fix is using the 'pull_request_target' event, which runs in the context of the base branch, and thus with a read-write token. See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target Also, added a warning message when no milestone without a release branch is found and thus the newest existing milestone is assigned (this is a fallback that should normally not happen). --- .github/workflows/pull-request-post-merge-processing.yml | 4 ++-- .github/workflows/scripts/assign-milestone-to-merged-pr.php | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull-request-post-merge-processing.yml b/.github/workflows/pull-request-post-merge-processing.yml index 1347ed5e5e1..68f649a6a45 100644 --- a/.github/workflows/pull-request-post-merge-processing.yml +++ b/.github/workflows/pull-request-post-merge-processing.yml @@ -1,6 +1,6 @@ name: "Pull request post-merge processing" -on: - pull_request: +on: + pull_request_target: types: [closed] jobs: diff --git a/.github/workflows/scripts/assign-milestone-to-merged-pr.php b/.github/workflows/scripts/assign-milestone-to-merged-pr.php index e563cdd97db..74f42c4b63a 100644 --- a/.github/workflows/scripts/assign-milestone-to-merged-pr.php +++ b/.github/workflows/scripts/assign-milestone-to-merged-pr.php @@ -85,6 +85,7 @@ foreach ( $milestones as $milestone ) { // If all the milestones have a release branch, just take the newest one. if ( is_null( $chosen_milestone ) ) { + echo "WARNING: No milestone without release branch found, the newest one will be assigned.\n"; $chosen_milestone = $milestones[0]; }