mirror of https://github.com/actions/toolkit
5afccaa9db | ||
---|---|---|
.. | ||
__tests__ | ||
dist | ||
src | ||
LICENSE.md | ||
README.md | ||
package-lock.json | ||
package.json | ||
tsconfig.json |
README.md
@actions/oidc-client
Usage
You can use this package to interact with the GitHub OIDC provider and get a JWT ID token which would help to get access token from third party cloud providers.
Get the ID token
Method Name: getIDToken
Inputs
audience : optional
Outputs
A JWT ID Token
Example:
You can use this template to use the package.
main.ts
const core = require('@actions/core');
const id = require('@actions/oidc-client')
async function getIDTokenAction(): Promise<void> {
let aud = ''
const audience = core.getInput('audience', {required: false})
if (audience !== undefined)
aud = `${audience}`
const id_token = await id.getIDToken(aud)
const val = `ID token is ${id_token}`
core.setOutput('id_token', id_token);
}
getIDTokenAction()
actions.yml
name: 'GetIDToken'
description: 'Get ID token from Github OIDC provider'
inputs:
audience:
description: 'Audience for which the ID token is intended for'
required: false
outputs:
id_token:
description: 'ID token obtained from OIDC provider'
runs:
using: 'node12'
main: 'dist/index.js'