Skip to content

Commit

Permalink
API token is needed
Browse files Browse the repository at this point in the history
  • Loading branch information
anomiex committed Jan 21, 2025
1 parent a2edd37 commit 597d342
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
11 changes: 6 additions & 5 deletions .github/files/coverage-munger/upload-coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Environment used by this script:
#
# Required:
# - API_TOKEN_GITHUB: GitHub API token.
# - GITHUB_API_URL: GitHub API URL.
# - GITHUB_TOKEN: GitHub API token.
# - GITHUB_REPOSITORY: GitHub repo.
Expand Down Expand Up @@ -114,7 +115,7 @@ if [[ "$PR_ID" != "trunk" ]]; then
jq . <<<"$JSON"
curl -v -L --fail \
--url "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/statuses/$( jq --arg V "$PR_HEAD" -nr '$V | @uri' )" \
--header "authorization: Bearer $API_TOKEN" \
--header "authorization: Bearer $API_TOKEN_GITHUB" \
--header 'content-type: application/json' \
--data "$( jq -c --arg PR "$PR_ID" '{
context: "Code coverage requirement",
Expand All @@ -128,7 +129,7 @@ if [[ "$PR_ID" != "trunk" ]]; then
while true; do
J=$( curl -v -L fail \
--url "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/issues/${ID}/comments?per_page=100&page=$PAGE" \
--header "authorization: Bearer $API_TOKEN"
--header "authorization: Bearer $API_TOKEN_GITHUB"
)
CID=$( jq -r --arg CID "$CID" '[ { id: $CID }, ( .[] | select( .user.login == "github-actions[bot]" ) | select( .body | test( "^### Code Coverage Summary" ) ) ) ] | last | .id' <<<"$J" )
if jq -e 'length < 100' <<<"$J"; then
Expand All @@ -142,7 +143,7 @@ if [[ "$PR_ID" != "trunk" ]]; then
curl -v -L --fail \
-X PATCH
--url "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/issues/comments/${CID}" \
--header "authorization: Bearer $API_TOKEN" \
--header "authorization: Bearer $API_TOKEN_GITHUB" \
--header 'content-type: application/json' \
--data "$( jq -c '{
body: "### Code Coverage Summary\n\n\( .msg )\n\n\( .footer )",
Expand All @@ -151,7 +152,7 @@ if [[ "$PR_ID" != "trunk" ]]; then
curl -v -L --fail \
-X POST
--url "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/issues/${ID}/comments" \
--header "authorization: Bearer $API_TOKEN" \
--header "authorization: Bearer $API_TOKEN_GITHUB" \
--header 'content-type: application/json' \
--data "$( jq -c '{
body: "### Code Coverage Summary\n\n\( .msg )\n\n\( .footer )",
Expand All @@ -162,7 +163,7 @@ if [[ "$PR_ID" != "trunk" ]]; then
curl -v -L --fail \
-X delete
--url "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/issues/comments/${CID}" \
--header "authorization: Bearer $API_TOKEN"
--header "authorization: Bearer $API_TOKEN_GITHUB"
fi
echo "::endgroup::"
fi
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ jobs:
SECRET: ${{ secrets.CODECOV_SECRET }}
STATUS: ${{ needs.run-tests.outputs.coverage-status }}
PR_HEAD: ${{ github.event.pull_request.head.sha }}
API_TOKEN_GITHUB: ${{ secrets.GITHUB_TOKEN }}
run: .github/files/coverage-munger/upload-coverage.sh

storybook-test:
Expand Down

0 comments on commit 597d342

Please sign in to comment.