Skip to content

Commit 650f95a

Browse files
committed
fix(ci): avoid agentic auth comment failure
Signed-off-by: Andre Manoel <amanoel@nvidia.com>
1 parent aa69207 commit 650f95a

1 file changed

Lines changed: 22 additions & 14 deletions

File tree

.github/workflows/authorize-agentic-ci.yml

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ jobs:
4141
admin|maintain|write)
4242
;;
4343
*)
44-
gh issue comment "$PR_NUMBER" --repo "$REPO" --body \
45-
"Only maintainers with write access can authorize Agentic CI checks."
44+
gh api --method POST "repos/${REPO}/issues/${PR_NUMBER}/comments" \
45+
-f body="Only maintainers with write access can authorize Agentic CI checks." >/dev/null
4646
exit 1
4747
;;
4848
esac
@@ -89,21 +89,29 @@ jobs:
8989
STATE: ${{ steps.pr.outputs.state }}
9090
TRUSTED: ${{ steps.pr.outputs.trusted }}
9191
run: |
92+
comment() {
93+
gh api --method POST "repos/${REPO}/issues/${PR_NUMBER}/comments" \
94+
-f body="$1" >/dev/null
95+
}
96+
97+
comment_file() {
98+
jq -n --rawfile body "$1" '{body: $body}' > /tmp/agentic-ci-auth-comment.json
99+
gh api --method POST "repos/${REPO}/issues/${PR_NUMBER}/comments" \
100+
--input /tmp/agentic-ci-auth-comment.json >/dev/null
101+
}
102+
92103
if [ "$STATE" != "open" ]; then
93-
gh issue comment "$PR_NUMBER" --repo "$REPO" --body \
94-
"Agentic CI checks were not authorized because this PR is not open."
104+
comment "Agentic CI checks were not authorized because this PR is not open."
95105
exit 1
96106
fi
97107
98108
if [ "$TRUSTED" != "true" ]; then
99-
gh issue comment "$PR_NUMBER" --repo "$REPO" --body \
100-
"Agentic CI checks were not authorized because this PR does not match the trusted Agentic CI metadata."
109+
comment "Agentic CI checks were not authorized because this PR does not match the trusted Agentic CI metadata."
101110
exit 1
102111
fi
103112
104113
if [ -z "$COMMENT_ID" ]; then
105-
gh issue comment "$PR_NUMBER" --repo "$REPO" --body \
106-
"Agentic CI checks were not authorized because the authorization comment ID was missing."
114+
comment "Agentic CI checks were not authorized because the authorization comment ID was missing."
107115
exit 1
108116
fi
109117
@@ -122,8 +130,7 @@ jobs:
122130
sleep 2
123131
done
124132
if [ "$COMMENT_FOUND" != "true" ]; then
125-
gh issue comment "$PR_NUMBER" --repo "$REPO" --body \
126-
"Agentic CI checks were not authorized because the authorization comment was not found in the PR timeline."
133+
comment "Agentic CI checks were not authorized because the authorization comment was not found in the PR timeline."
127134
exit 1
128135
fi
129136
@@ -143,7 +150,7 @@ jobs:
143150
echo
144151
echo "Please review the latest commit and comment \`/authorize-agentic-ci\` again."
145152
} > /tmp/agentic-ci-auth-stale.md
146-
gh issue comment "$PR_NUMBER" --repo "$REPO" --body-file /tmp/agentic-ci-auth-stale.md
153+
comment_file /tmp/agentic-ci-auth-stale.md
147154
exit 1
148155
fi
149156
@@ -155,7 +162,7 @@ jobs:
155162
echo
156163
printf '%s\n' "$BLOCKED" | sed 's/^/- `/' | sed 's/$/`/'
157164
} > /tmp/agentic-ci-auth-failed.md
158-
gh issue comment "$PR_NUMBER" --repo "$REPO" --body-file /tmp/agentic-ci-auth-failed.md
165+
comment_file /tmp/agentic-ci-auth-failed.md
159166
exit 1
160167
fi
161168
@@ -175,5 +182,6 @@ jobs:
175182
-f pr_number="$PR_NUMBER" \
176183
-f expected_head_sha="$HEAD_SHA"
177184
178-
gh issue comment "$PR_NUMBER" --repo "$REPO" --body \
179-
"Authorized Agentic CI checks for \`${HEAD_SHA}\`. Launched CI and authorization checks."
185+
gh api --method POST "repos/${REPO}/issues/${PR_NUMBER}/comments" \
186+
-f body="Authorized Agentic CI checks for \`${HEAD_SHA}\`. Launched CI and authorization checks." >/dev/null || \
187+
echo "::warning::Unable to post authorization confirmation comment."

0 commit comments

Comments
 (0)