Skip to content

Commit

Permalink
let's try this
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Hall <[email protected]>
  • Loading branch information
imjasonh committed Jan 28, 2024
1 parent 689ce5a commit ab13bda
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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); })
Expand Down

0 comments on commit ab13bda

Please sign in to comment.