File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4848 --jq '.[] | @json')
4949
5050 if [[ ${#prs[@]} -eq 0 ]]; then
51- echo "No open PRs with label '${UPDATE_LABEL}' target '${BASE_BRANCH}' — nothing to do."
51+ echo "No open PRs with label '${UPDATE_LABEL}' targeting '${BASE_BRANCH}' — nothing to do."
5252 exit 0
5353 fi
5454
@@ -92,14 +92,17 @@ jobs:
9292 GH_TOKEN : ${{ secrets.GH_PAT }}
9393 PR_NUMBER : ${{ github.event.pull_request.number }}
9494 run : |
95- # Check if the label is present before attempting removal .
96- has_label =$(gh pr view "$PR_NUMBER" \
95+ # Query labels first and fail explicitly if the GitHub CLI request fails .
96+ if ! pr_labels =$(gh pr view "$PR_NUMBER" \
9797 --repo "$GITHUB_REPOSITORY" \
9898 --json labels \
99- --jq --arg lbl "$UPDATE_LABEL" '.labels[].name | select(. == $lbl)' \
100- | grep -c . || true)
99+ --jq '.labels[].name'); then
100+ echo "Failed to read labels for PR #${PR_NUMBER}."
101+ exit 1
102+ fi
101103
102- if [[ "$has_label" -eq 0 ]]; then
104+ # Treat a missing label as a normal no-op, but do not mask query failures.
105+ if ! printf '%s\n' "$pr_labels" | grep -Fxq -- "$UPDATE_LABEL"; then
103106 echo "PR #${PR_NUMBER} does not have the '${UPDATE_LABEL}' label — nothing to do."
104107 exit 0
105108 fi
You can’t perform that action at this time.
0 commit comments