Skip to content

Commit 7658913

Browse files
committed
Rework action.sh script
1 parent ac79204 commit 7658913

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

action.sh

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,28 @@
11
#!/bin/bash
22

33
if [[ -z "${ACTIONS_ID_TOKEN_REQUEST_URL}" ]] && [[ -z "${ACTIONS_ID_TOKEN_REQUEST_TOKEN}" ]]; then
4-
echo "==> No GitHub OIDC token found, skipping..."
4+
echo "::error:: The job or workflow run requires a permissions setting with id-token: write.\nYou won't be able to request the OIDC JWT ID token if the permissions setting for id-token is set to read or none.\nThe \`id-token: write\` setting allows the JWT to be requested from GitHub's OIDC provider."
55
exit 0
66
fi
77

8+
if [ ! "$(command -v dart)" ] && [ ! "$(command -v flutter)" ]; then
9+
echo "::error::Flutter is not installed,"
10+
echo "See https://github.com/flutter-actions/setup-flutter for more details."
11+
exit 1
12+
fi
13+
814
log_group_start() {
915
echo "::group::${1}"
1016
}
1117
log_group_end() {
1218
echo "::endgroup::"
1319
}
1420

15-
jwtd() {
16-
log_group_start "Decoding JWT data..."
17-
jq -R 'split(".") | .[0],.[1] | @base64d | fromjson' <<< "${1}"
18-
echo "Signature: $(echo "${1}" | awk -F'.' '{print $3}')"
19-
log_group_end
20-
}
21-
22-
INPUT_GITHUB_OIDC_AUDIENCE="https://pub.dev"
23-
2421
echo "Create the OIDC token used for pub.dev publishing..."
22+
INPUT_GITHUB_OIDC_AUDIENCE="https://pub.dev"
2523
GITHUB_OIDC_RESPONSE=$(curl -s -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=${INPUT_GITHUB_OIDC_AUDIENCE}")
2624
GITHUB_OIDC_IDTOKEN=$(jq -r '.value' <<< "${GITHUB_OIDC_RESPONSE}")
2725
export PUB_TOKEN=${GITHUB_OIDC_IDTOKEN}
2826
echo "PUB_TOKEN=${GITHUB_OIDC_IDTOKEN}" >> $GITHUB_ENV
29-
30-
jwtd "$GITHUB_OIDC_IDTOKEN"
31-
3227
echo "The Dart CLI successfully authenticated with the GitHub OIDC token,"
3328
dart pub token add ${INPUT_GITHUB_OIDC_AUDIENCE} --env-var PUB_TOKEN

0 commit comments

Comments
 (0)