Skip to content

Commit 3906087

Browse files
committed
Automatically create OIDC token for pub.dev.
1 parent 196f545 commit 3906087

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

setup.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,11 @@ echo "${RUNNER_TOOL_CACHE}/dart-sdk/bin" >> $GITHUB_PATH
104104
# Report success, and print version.
105105
echo -e "Successfully installed Dart SDK:"
106106
${RUNNER_TOOL_CACHE}/dart-sdk/bin/dart --version
107+
108+
# When enabled through env variables, create OIDC token for publishing on pub.dev.
109+
if [[ "${ACTIONS_ID_TOKEN_REQUEST_URL}" != "" && "${ACTIONS_ID_TOKEN_REQUEST_TOKEN}" != "" ]]
110+
then
111+
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')
112+
echo "PUB_TOKEN=${PUB_TOKEN}" >> $GITHUB_ENV
113+
${RUNNER_TOOL_CACHE}/dart-sdk/bin/dart pub token add https://pub.dev --env-var PUB_TOKEN
114+
fi

0 commit comments

Comments
 (0)