pr-check: Auto lock blocked PRs with too many failing builds

This commit is contained in:
bbhtt
2025-07-30 18:55:17 +05:30
parent ec85636219
commit ee084337aa
+14 -1
View File
@@ -21,7 +21,7 @@ jobs:
CUTOFF_DATE="2025-05-25T00:00:00Z" CUTOFF_DATE="2025-05-25T00:00:00Z"
prs_raw=$(gh pr list --base "new-pr" -L 50 --state open --json number,createdAt,updatedAt,isDraft,labels \ prs_raw=$(gh pr list --base "new-pr" -L 50 --state open --json number,createdAt,updatedAt,isDraft,labels \
| jq -r --arg cutoff "$CUTOFF_DATE" '[. | jq -r --arg cutoff "$CUTOFF_DATE" '[.
[] []
| select( | select(
.isDraft == false .isDraft == false
and .createdAt >= $cutoff and .createdAt >= $cutoff
@@ -149,6 +149,14 @@ jobs:
echo "Nothing to do" echo "Nothing to do"
start_build start_build
fi fi
if [ "$BLOCKED" -eq 1 ] \
&& label_exists_any "pr-check-blocked" "blocked" \
&& ! comment_exists_any "$BUILD_SUCCESS_COMMENT" \
&& [ "$(echo "$PR_COMMENTS" | grep -E -c 'Test build.*failed')" -gt 10 ]; then
echo "PR is blocked and too many failing builds. Locking"
gh pr comment "$PR_NUM" --body "$LOCKED_COMMENT"
gh pr lock "$PR_NUM" || true
fi
done done
env: env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -168,4 +176,9 @@ jobs:
request title is `Add $FLATPAK_ID` and that all request title is `Add $FLATPAK_ID` and that all
[checklist items](https://github.com/flathub/flathub/blob/master/.github/pull_request_template.md) [checklist items](https://github.com/flathub/flathub/blob/master/.github/pull_request_template.md)
in the pull request body are marked as complete. in the pull request body are marked as complete.
LOCKED_COMMENT: >
This pull request is marked as blocked and has too many
builds failing. Locking this PR temporarily. Please build
it locally following the instructions and push the relevant
changes first.
REVIEW_COMMENT_PARTIAL: "This pull request is temporarily marked as blocked as some" REVIEW_COMMENT_PARTIAL: "This pull request is temporarily marked as blocked as some"