From fb5e7cfe386e62dd8ece546af4ddaa33b76f9a29 Mon Sep 17 00:00:00 2001 From: bbhtt Date: Sun, 31 Aug 2025 08:08:24 +0530 Subject: [PATCH] pr-check: Label draft PRs automatically --- .github/workflows/pr-check.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index b143861..4db6322 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -36,10 +36,40 @@ jobs: ] | .[]') prs_list=$(printf '%s\n' $prs_raw | head -30 | paste -sd "," -) echo "PR_LIST=$prs_list" >> "$GITHUB_ENV" + draft_prs_raw=$(gh pr list --base "new-pr" -L 50 --state open --json number,createdAt,updatedAt,isDraft,labels \ + | jq -r --arg cutoff "$CUTOFF_DATE" '[. + [] + | select( + .isDraft == true + and .createdAt >= $cutoff + and .updatedAt >= (now - (2 * 24 * 60 * 60) | todate) + and (all(.labels[].name; . != "Stale") or (.labels == [])) + ) + | .number + ] | .[]') + draft_prs_list=$(printf '%s\n' $draft_prs_raw | head -30 | paste -sd "," -) + echo "DRAFT_PR_LIST=$draft_prs_list" >> "$GITHUB_ENV" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_REPO: ${{ github.repository }} + - name: Label draft PRs + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + run: | + IFS=',' read -ra PR_NUMBERS <<< "${{ env.DRAFT_PR_LIST }}" + + if [ ${#PR_NUMBERS[@]} -eq 0 ] || [ -z "${PR_NUMBERS[0]}" ]; then + echo "No PRs found, exiting." + exit 0 + fi + + for PR_NUM in "${PR_NUMBERS[@]}"; do + echo "Checking PR https://github.com/flathub/flathub/pull/$PR_NUM" + gh pr edit "$PR_NUM" --add-label "work-in-progress" || true + done + - name: Validate PRs run: | IFS=',' read -ra PR_NUMBERS <<< "${{ env.PR_LIST }}"