File tree Expand file tree Collapse file tree 2 files changed +17
-9
lines changed Expand file tree Collapse file tree 2 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -5,10 +5,14 @@ export namespace Action {
5
5
export async function run ( ) {
6
6
try {
7
7
const token = await Util . getAppToken ( )
8
- await Util . saveAppTokenToSecret ( token )
8
+ core . info ( 'Token generated!' )
9
+ const secretName = core . getInput ( 'SECRET_NAME' )
10
+ if ( secretName ) {
11
+ await Util . saveAppTokenToSecret ( secretName , token )
12
+ core . info ( `Token save in secret "${ secretName } "` )
13
+ }
9
14
core . setSecret ( token )
10
15
core . setOutput ( 'token' , token )
11
- core . info ( 'Token generated!' )
12
16
} catch ( e ) {
13
17
core . error ( e )
14
18
core . setFailed ( e . message )
@@ -17,8 +21,11 @@ export namespace Action {
17
21
18
22
export async function cleanup ( ) {
19
23
try {
20
- await Util . removeAppTokenFromSecret ( )
21
- core . info ( 'Token cleaned!' )
24
+ const secretName = core . getInput ( 'SECRET_NAME' )
25
+ if ( secretName ) {
26
+ await Util . removeAppTokenFromSecret ( secretName )
27
+ core . info ( `Token in secret "${ secretName } " was cleaned` )
28
+ }
22
29
} catch ( e ) {
23
30
core . error ( e )
24
31
core . setFailed ( e . message )
Original file line number Diff line number Diff line change 1
1
import { context , getOctokit } from '@actions/github'
2
- import { Octokit } from '@octokit/core'
3
2
import { getInput } from '@actions/core'
3
+ import { Octokit } from '@octokit/core'
4
4
import { App } from '@octokit/app'
5
5
import isBase64 from 'is-base64'
6
6
import sodium from 'tweetsodium'
@@ -24,15 +24,16 @@ export namespace Util {
24
24
} )
25
25
}
26
26
27
- export async function saveAppTokenToSecret ( token : string ) {
28
- const secretName = getInput ( 'SECRET_NAME' )
27
+ export async function saveAppTokenToSecret (
28
+ secretName : string ,
29
+ token : string ,
30
+ ) {
29
31
if ( secretName ) {
30
32
return createOrUpdateRepoSecret ( token , secretName , token )
31
33
}
32
34
}
33
35
34
- export async function removeAppTokenFromSecret ( ) {
35
- const secretName = getInput ( 'SECRET_NAME' )
36
+ export async function removeAppTokenFromSecret ( secretName : string ) {
36
37
if ( secretName ) {
37
38
const token = await getAppToken ( )
38
39
return Util . deleteSecret ( token , secretName )
You can’t perform that action at this time.
0 commit comments