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); })