From 3b4bdcb33baf5c62c8246a8c8f5fd167b7b0475a Mon Sep 17 00:00:00 2001 From: Kate Lovett Date: Tue, 17 Nov 2026 11:28:37 -0600 Subject: [PATCH] [ci] update workflow permissions --- .github/workflows/labeler.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index a4a2e23..ba89072 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -46,7 +46,8 @@ jobs: permissions: actions: read checks: read - contents: read + # Required for convertPullRequestToDraft and collaborator membership checks. + contents: write pull-requests: write runs-on: ubuntu-latest steps: @@ -163,7 +164,7 @@ jobs: sync-labels: true - name: Check PR template - if: steps.validate.outputs.pr_number != '' + if: steps.validate.outputs.pr_number != '' && steps.cla.outputs.cla_passed == 'true' env: GH_TOKEN: ${{ github.token }} PR_NUMBER: ${{ steps.validate.outputs.pr_number }} @@ -188,10 +189,17 @@ jobs: echo "::notice::Skipping bot author $AUTHOR." exit 0 fi - if [[ "$ASSOC" == "MEMBER" || "$ASSOC" == "OWNER" || "$ASSOC" == "COLLABORATOR" ]] || - gh api --silent "repos/$REPO/collaborators/$AUTHOR" 2>/dev/null; then + if [[ "$ASSOC" == "MEMBER" || "$ASSOC" == "OWNER" || "$ASSOC" == "COLLABORATOR" ]]; then + echo "::notice::Author $AUTHOR is an org member/collaborator; skipping template check." + exit 0 + fi + COLLAB_STATUS=$(gh api -i "repos/$REPO/collaborators/$AUTHOR" 2>/dev/null | awk 'NR==1 {print $2}' || true) + if [ "$COLLAB_STATUS" = "204" ]; then echo "::notice::Author $AUTHOR is an org member/collaborator; skipping template check." exit 0 + elif [ "$COLLAB_STATUS" != "404" ]; then + echo "::error::Unexpected HTTP status '${COLLAB_STATUS:-empty}' checking collaborator status for $AUTHOR." + exit 1 fi # 3. Validate the PR description against .github/PULL_REQUEST_TEMPLATE.md.