Skip to content

Commit 5226aac

Browse files
TimonBtimonbirk
andauthored
Improve error handling in OIDC auth (#7)
* Check if ACTIONS_ID_TOKEN_REQUEST_URL env variable is set and echo specific error message --------- Co-authored-by: timonbirk <email@timonbirk.de>
1 parent a865809 commit 5226aac

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/main.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ async function run() {
2727
core.exportVariable("CLOUDSMITH_API_KEY", apiKey);
2828
core.info("Using provided API key for authentication.");
2929
} else if (orgName && serviceAccountSlug) {
30+
31+
if (!process.env.ACTIONS_ID_TOKEN_REQUEST_URL) {
32+
throw new Error("Environment variable ACTIONS_ID_TOKEN_REQUEST_URL is not set. Did you add the permission 'id-token: write' to your workflow?");
33+
}
34+
3035
await oidcAuth.authenticate(orgName, serviceAccountSlug, apiHost, oidcAuthRetry);
3136
} else {
3237
throw new Error("Either API key or OIDC inputs (namespace and service account slug) must be provided for authentication.");

0 commit comments

Comments
 (0)