Skip to content

Commit

Permalink
Automatically create OIDC token for pub.dev.
Browse files Browse the repository at this point in the history
  • Loading branch information
isoos committed Sep 12, 2022
1 parent 196f545 commit 3906087
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,11 @@ echo "${RUNNER_TOOL_CACHE}/dart-sdk/bin" >> $GITHUB_PATH
# Report success, and print version.
echo -e "Successfully installed Dart SDK:"
${RUNNER_TOOL_CACHE}/dart-sdk/bin/dart --version

# When enabled through env variables, create OIDC token for publishing on pub.dev.
if [[ "${ACTIONS_ID_TOKEN_REQUEST_URL}" != "" && "${ACTIONS_ID_TOKEN_REQUEST_TOKEN}" != "" ]]
then
PUB_TOKEN=$(curl --retry 5 --retry-connrefused -sLS "${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=https://pub.dev" -H "User-Agent: actions/oidc-client" -H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" | jq -r '.value')
echo "PUB_TOKEN=${PUB_TOKEN}" >> $GITHUB_ENV
${RUNNER_TOOL_CACHE}/dart-sdk/bin/dart pub token add https://pub.dev --env-var PUB_TOKEN
fi

0 comments on commit 3906087

Please sign in to comment.