@@ -110,7 +110,7 @@ jobs:
110110 permissions :
111111 contents : write
112112 issues : write
113- pull-requests : read
113+ pull-requests : write
114114 steps :
115115 - name : Download analysis artifact
116116 uses : actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
@@ -147,14 +147,24 @@ jobs:
147147 env :
148148 GH_TOKEN : ${{ github.token }}
149149 run : |
150- gh pr edit ${{ github.event.pull_request.number }} --add-label "breaking-change-analyzed"
150+ gh api \
151+ --method POST \
152+ -H "Accept: application/vnd.github+json" \
153+ "/repos/$GITHUB_REPOSITORY/issues/${{ github.event.pull_request.number }}/labels" \
154+ -f labels[]="breaking-change-analyzed" \
155+ --silent
151156
152157 - name : Add breaking-change label if applicable
153158 if : steps.analysis.outputs.has_breaking_changes == 'true'
154159 env :
155160 GH_TOKEN : ${{ github.token }}
156161 run : |
157- gh pr edit ${{ github.event.pull_request.number }} --add-label "breaking-change"
162+ gh api \
163+ --method POST \
164+ -H "Accept: application/vnd.github+json" \
165+ "/repos/$GITHUB_REPOSITORY/issues/${{ github.event.pull_request.number }}/labels" \
166+ -f labels[]="breaking-change" \
167+ --silent
158168
159169 - name : Post analysis result to PR
160170 env :
@@ -165,7 +175,8 @@ jobs:
165175 run : |
166176 # Use temp file to avoid shell escaping issues with special characters
167177 TMPFILE=$(mktemp)
168- trap 'rm -f "$TMPFILE"' EXIT
178+ TMPJSON=$(mktemp)
179+ trap 'rm -f "$TMPFILE" "$TMPJSON"' EXIT
169180
170181 # Build comment using printf to avoid YAML parsing issues with markdown
171182 {
@@ -182,7 +193,14 @@ jobs:
182193 printf '*This analysis was performed by Claude Code Action*\n'
183194 } > "$TMPFILE"
184195
185- gh pr comment ${{ github.event.pull_request.number }} --body-file "$TMPFILE"
196+ jq -n --rawfile body "$TMPFILE" '{body: $body}' > "$TMPJSON"
197+
198+ gh api \
199+ --method POST \
200+ -H "Accept: application/vnd.github+json" \
201+ "/repos/$GITHUB_REPOSITORY/issues/${{ github.event.pull_request.number }}/comments" \
202+ --input "$TMPJSON" \
203+ --silent
186204
187205 - name : Calculate version and update draft release
188206 env :
@@ -193,7 +211,7 @@ jobs:
193211 set -euo pipefail
194212
195213 # Get latest published release tag and strip "v" prefix if present
196- LATEST_TAG_RAW=$(gh release list --limit 1 --exclude-drafts --json tagName --jq '.[0].tagName // "0.0.0"')
214+ LATEST_TAG_RAW=$(gh release list --repo "$GITHUB_REPOSITORY" -- limit 1 --exclude-drafts --json tagName --jq '.[0].tagName // "0.0.0"')
197215 LATEST_TAG="${LATEST_TAG_RAW#v}"
198216 LATEST_TAG="${LATEST_TAG#V}"
199217 echo "Latest published tag: $LATEST_TAG_RAW (parsed as: $LATEST_TAG)"
@@ -213,7 +231,7 @@ jobs:
213231
214232 # Check if draft release exists (use jq to extract first draft tag safely)
215233 # Keep raw tag name for gh commands, strip prefix only for version comparison
216- DRAFT_TAG_RAW=$(gh release list --json tagName,isDraft --jq '[.[] | select(.isDraft == true)] | .[0].tagName // ""')
234+ DRAFT_TAG_RAW=$(gh release list --repo "$GITHUB_REPOSITORY" -- json tagName,isDraft --jq '[.[] | select(.isDraft == true)] | .[0].tagName // ""')
217235 DRAFT_TAG="${DRAFT_TAG_RAW#v}"
218236 DRAFT_TAG="${DRAFT_TAG#V}"
219237 BC_SOURCE_TAG_RAW="$DRAFT_TAG_RAW"
@@ -274,7 +292,7 @@ jobs:
274292 # Get existing draft body if updating (only if DRAFT_TAG_RAW is set, meaning we're updating same version)
275293 EXISTING_BC=""
276294 if [ -n "$BC_SOURCE_TAG_RAW" ]; then
277- EXISTING_BODY=$(gh release view "$BC_SOURCE_TAG_RAW" --json body --jq '.body // ""')
295+ EXISTING_BODY=$(gh release view "$BC_SOURCE_TAG_RAW" --repo "$GITHUB_REPOSITORY" -- json body --jq '.body // ""')
278296 # Extract existing Breaking Changes section content
279297 # Use awk for precise extraction - stops at any ## header that's not "## Breaking Changes"
280298 if echo "$EXISTING_BODY" | grep -q '^## Breaking Changes$'; then
@@ -336,19 +354,21 @@ jobs:
336354 if [ -n "$DRAFT_TAG_RAW" ] && [ "$DRAFT_TAG" = "$NEXT_VERSION" ]; then
337355 echo "Updating existing draft release: $DRAFT_TAG_RAW"
338356 echo "$RELEASE_BODY" | gh release edit "$DRAFT_TAG_RAW" \
357+ --repo "$GITHUB_REPOSITORY" \
339358 --title "$NEXT_VERSION" \
340359 --notes-file -
341360 else
342361 echo "Creating new draft release: $NEXT_VERSION"
343362 # Create new draft first, then delete old one (to prevent data loss)
344363 if echo "$RELEASE_BODY" | gh release create "$NEXT_VERSION" \
364+ --repo "$GITHUB_REPOSITORY" \
345365 --title "$NEXT_VERSION" \
346366 --notes-file - \
347367 --draft; then
348368 # Only delete old draft after successful creation
349369 if [ -n "$OLD_DRAFT_TAG" ]; then
350370 echo "Deleting old draft: $OLD_DRAFT_TAG"
351- gh release delete "$OLD_DRAFT_TAG" --yes 2>/dev/null || true
371+ gh release delete "$OLD_DRAFT_TAG" --repo "$GITHUB_REPOSITORY" -- yes 2>/dev/null || true
352372 fi
353373 else
354374 echo "Failed to create new draft release"
0 commit comments