1
0
Fork 0
toolkit/packages/oidc-client/README.md

59 lines
1.2 KiB
Markdown
Raw Normal View History

2021-07-27 04:17:27 +00:00
<h2>@actions/oidc-client</h2>
2021-07-01 02:41:28 +00:00
<h3>Usage</h3>
2021-07-28 10:24:05 +00:00
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.
2021-07-01 02:41:28 +00:00
<h3>Get the ID token</h3>
Method Name: getIDToken
<h3>Inputs</h3>
2021-07-26 10:20:36 +00:00
audience : optional
2021-07-01 02:41:28 +00:00
2021-07-28 10:24:05 +00:00
<h3>Outputs</h3>
A [JWT](https://jwt.io/) ID Token
2021-07-01 02:41:28 +00:00
<h3>Example:</h3>
2021-07-28 10:26:10 +00:00
You can use this [template](https://github.com/actions/typescript-action) to use the package.
2021-07-28 08:31:17 +00:00
main.ts
2021-07-01 02:41:28 +00:00
```
const core = require('@actions/core');
const id = require('@actions/oidc-client')
2021-07-28 10:24:05 +00:00
async function getIDTokenAction(): Promise<void> {
2021-07-28 08:31:17 +00:00
let aud = ''
const audience = core.getInput('audience', {required: false})
if (audience !== undefined)
aud = `${audience}`
const id_token = await id.getIDToken(aud)
2021-07-01 02:41:28 +00:00
const val = `ID token is ${id_token}`
core.setOutput('id_token', id_token);
}
2021-07-28 10:24:05 +00:00
getIDTokenAction()
2021-07-01 02:41:28 +00:00
```
2021-07-28 08:31:17 +00:00
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'
```