From ab13bda9c49091033ff84eea9e17fa94160266c8 Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Sun, 28 Jan 2024 10:30:39 -0500 Subject: [PATCH] let's try this Signed-off-by: Jason Hall --- index.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index e7cdfe3..3f54ba7 100644 --- a/index.js +++ b/index.js @@ -6,15 +6,23 @@ if (!actionsToken || !actionsUrl) { process.exit(1); } +const scope = process.env.INPUT_scope; +const identity = process.env.INPUT_identity; + +if (!scope || !identity) { + console.log(`::error::Missing required inputs 'scope' and 'identity'`); + process.exit(1); +} + fetch(`${actionsUrl}&audience=octo-sts.dev`, { headers: { 'Authorization': `Bearer ${actionsToken}` } }) .then(res => { + console.log('Fetching workflow OIDC...'); console.log(res.status); res.json() .then(json => { - console.log(json) - const ghtok = json.token; - const scope = process.env.INPUT_scope; - const identity = process.env.INPUT_identity; + console.log('Got JSON', json); + const ghtok = json.value; + console.log('Fetching from octo-sts.dev...'); fetch(`https://octo-sts.dev/sts/exchange?scope=${scope}&identity=${identity}`, { headers: { 'Authorization': `Bearer ${ghtok}` } }) .then(res => res.json() .catch(err => { console.log(`::error::${err.stack}`); process.exit(1); })