chore(ci): add preflight token and API checks
This commit is contained in:
@@ -64,6 +64,34 @@ runs:
|
||||
|
||||
printf 'pr_number=%s\n' "$PR_NUMBER" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Preflight comment API access
|
||||
id: preflight
|
||||
shell: bash
|
||||
env:
|
||||
AUTH_TOKEN: ${{ inputs.token != '' && inputs.token || github.token }}
|
||||
PR_NUMBER: ${{ steps.validate.outputs.pr_number }}
|
||||
SERVER_URL: ${{ github.server_url }}
|
||||
REPOSITORY: ${{ github.repository }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
if [[ -z "$AUTH_TOKEN" ]]; then
|
||||
echo "No token available for PR comment API calls. Set input token or provide workflow token." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
api_url="${SERVER_URL}/api/v1"
|
||||
if [[ "$SERVER_URL" == *"github.com"* ]]; then
|
||||
api_url="https://api.github.com"
|
||||
fi
|
||||
|
||||
comments_url="${api_url}/repos/${REPOSITORY}/issues/${PR_NUMBER}/comments"
|
||||
|
||||
curl --fail-with-body -sS \
|
||||
-H "Authorization: Bearer ${AUTH_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"$comments_url" >/dev/null
|
||||
|
||||
- name: Extract changelog unreleased entries
|
||||
id: extract-changelog
|
||||
shell: bash
|
||||
|
||||
Reference in New Issue
Block a user