mirror of https://github.com/actions/toolkit
Updated Readme
parent
58dfa1c4ac
commit
330dc0b5b8
|
@ -12,15 +12,22 @@ Method Name: getIDToken
|
||||||
|
|
||||||
audience : optional
|
audience : optional
|
||||||
|
|
||||||
|
You can use this [template](https://github.com/actions/typescript-action) to use the package.
|
||||||
<h3>Example:</h3>
|
<h3>Example:</h3>
|
||||||
|
|
||||||
|
main.ts
|
||||||
```
|
```
|
||||||
const core = require('@actions/core');
|
const core = require('@actions/core');
|
||||||
const id = require('@actions/oidc-client')
|
const id = require('@actions/oidc-client')
|
||||||
|
|
||||||
|
|
||||||
async function getID(){
|
async function getID(): Promise<void> {
|
||||||
const id_token = await id.getIDToken('client-id', 'client-secret')
|
|
||||||
|
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}`
|
const val = `ID token is ${id_token}`
|
||||||
core.setOutput('id_token', id_token);
|
core.setOutput('id_token', id_token);
|
||||||
|
|
||||||
|
@ -28,3 +35,19 @@ async function getID(){
|
||||||
|
|
||||||
getID()
|
getID()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
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'
|
||||||
|
```
|
||||||
|
|
Loading…
Reference in New Issue