mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
tools: label PRs lacking second approval
Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: https://github.com/nodejs/node/pull/65538 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Tierney Cyren <hello@bnb.im>
This commit is contained in:
1 parent
8bc17b0c7a
commit
0cdd3171c0
3 files changed
+69
-5
No files matched your search
@@ -28,6 +28,7 @@ jobs:
|
||||
if: github.repository == 'nodejs/node'
|
||||
runs-on: ubuntu-slim
|
||||
outputs:
|
||||
aged_prs: ${{ steps.get_candidate_prs.outputs.aged_prs }}
|
||||
candidates: ${{ steps.get_candidate_prs.outputs.candidates }}
|
||||
steps:
|
||||
- name: Get Pull Request Candidates
|
||||
@@ -50,6 +51,7 @@ jobs:
|
||||
--search "-label:blocked")
|
||||
candidates=$(printf '%s %s\n' "$fast_track_prs" "$aged_prs" |
|
||||
jq -r -s 'reduce .[] as $pr ([]; if index($pr) then . else . + [$pr] end) | join(" ")')
|
||||
echo "aged_prs=$aged_prs" >> "$GITHUB_OUTPUT"
|
||||
echo "candidates=$candidates" >> "$GITHUB_OUTPUT"
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
@@ -93,6 +95,7 @@ jobs:
|
||||
curl -fsSLo "$readme" "https://github.com/${GITHUB_REPOSITORY}/raw/${GITHUB_SHA}/README.md"
|
||||
|
||||
numbers=
|
||||
lacks_second_approval_prs=
|
||||
# shellcheck disable=SC2086
|
||||
for pr in $CANDIDATES; do
|
||||
metadata="${RUNNER_TEMP}/metadata-${pr}.json"
|
||||
@@ -139,6 +142,14 @@ jobs:
|
||||
if [ "$metadata_status" -ge 20 ] && [ "$metadata_status" -le 29 ]; then
|
||||
echo "pr ${pr} skipped, not ready to land"
|
||||
echo "reason codes: ${metadata_reason_codes}"
|
||||
if jq -e '
|
||||
(.reasonCodes | index("wait-time")) and
|
||||
(.pullRequest.labels | index("lacks-second-approval") | not)
|
||||
' "$metadata" > /dev/null; then
|
||||
case " $AGED_PRS " in
|
||||
*" $pr "*) lacks_second_approval_prs="$lacks_second_approval_prs $pr" ;;
|
||||
esac
|
||||
fi
|
||||
continue
|
||||
fi
|
||||
|
||||
@@ -148,11 +159,27 @@ jobs:
|
||||
done
|
||||
|
||||
numbers=$(echo "$numbers" | xargs)
|
||||
lacks_second_approval_prs=$(echo "$lacks_second_approval_prs" | xargs)
|
||||
echo "numbers=$numbers" >> "$GITHUB_OUTPUT"
|
||||
echo "lacks_second_approval_prs=$lacks_second_approval_prs" >> "$GITHUB_OUTPUT"
|
||||
env:
|
||||
AGED_PRS: ${{ needs.get_candidate_prs.outputs.aged_prs }}
|
||||
CANDIDATES: ${{ needs.get_candidate_prs.outputs.candidates }}
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
|
||||
- name: Label Pull Requests Lacking a Second Approval
|
||||
if: steps.get_mergeable_prs.outputs.lacks_second_approval_prs != ''
|
||||
run: |
|
||||
# shellcheck disable=SC2086
|
||||
for pr in $PULL_REQUESTS; do
|
||||
if ! gh -R "$GITHUB_REPOSITORY" pr edit "$pr" --add-label 'lacks-second-approval'; then
|
||||
echo "::warning::Failed to add lacks-second-approval to PR ${pr}"
|
||||
fi
|
||||
done
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GH_USER_TOKEN }}
|
||||
PULL_REQUESTS: ${{ steps.get_mergeable_prs.outputs.lacks_second_approval_prs }}
|
||||
|
||||
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
if: steps.get_mergeable_prs.outputs.numbers != ''
|
||||
with:
|
||||
|
||||
Reference in new issue
Block a user