Skip to content

Commit 476f6b9

Browse files
committed
Default CLOUDSMITH_ORGANISATION to financial-times
1 parent cbbfcb2 commit 476f6b9

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/commands/authenticate_with_oidc.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,16 @@ parameters:
99
type: string
1010
steps:
1111
- run:
12-
name: Prepare script parameters
12+
name: Configure Cloudsmith organisation
13+
command: |
14+
if [ -z "$CLOUDSMITH_ORGANISATION" ]
15+
then
16+
echo "export CLOUDSMITH_ORGANISATION=\"financial-times\"" >> $BASH_ENV
17+
fi
18+
- run:
19+
name: Configure Cloudsmith service
1320
command: |
1421
echo "export CLOUDSMITH_SERVICE_IDENTIFIER=\"<<parameters.service_identifier>>\"" >> $BASH_ENV
1522
- run:
16-
name: Authenticate with OIDC and generate a temporary OIDC token
23+
name: Authenticate with OIDC
1724
command: <<include(scripts/authenticate_with_oidc.sh)>>

src/scripts/authenticate_with_oidc.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,23 @@
55

66
set +e
77

8+
if [ -z "$CLOUDSMITH_ORGANISATION" ]
9+
then
10+
echo "Unable to generate OIDC token. Environment variable CLOUDSMITH_ORGANISATION is not set."
11+
exit 1
12+
fi
13+
814
if [ -z "$CLOUDSMITH_SERVICE_IDENTIFIER" ]
915
then
1016
echo "Unable to generate OIDC token. Environment variable CLOUDSMITH_SERVICE_IDENTIFIER is not set."
1117
exit 1
1218
fi
1319

14-
echo "Generating Cloudsmith OIDC token for service account: $CLOUDSMITH_SERVICE_IDENTIFIER"
20+
echo "Generating Cloudsmith OIDC token for service account: $CLOUDSMITH_ORGANISATION/$CLOUDSMITH_SERVICE_IDENTIFIER"
1521

1622
RESPONSE=$(curl -X POST -H "Content-Type: application/json" \
1723
-d "{\"oidc_token\":\"$CIRCLE_OIDC_TOKEN_V2\", \"service_slug\":\"$CLOUDSMITH_SERVICE_IDENTIFIER\"}" \
18-
--silent --show-error "https://api.cloudsmith.io/openid/financial-times/")
24+
--silent --show-error "https://api.cloudsmith.io/openid/$CLOUDSMITH_ORGANISATION/")
1925

2026
CLOUDSMITH_OIDC_TOKEN=$(echo "$RESPONSE" | grep -o '"token": "[^"]*' | grep -o '[^"]*$')
2127

0 commit comments

Comments
 (0)