@@ -9,38 +9,15 @@ export namespace Util {
9
9
return github . getOctokit ( token )
10
10
}
11
11
12
- export async function createSecret (
13
- octokit : ReturnType < typeof getOctokit > ,
14
- value : string ,
15
- ) {
12
+ async function createSecret ( octokit : Octokit , value : string ) {
16
13
const repo = github . context . repo
17
-
18
- core . info ( `Repo: ${ JSON . stringify ( repo , null , 2 ) } ` )
19
-
20
- const oct = new Octokit ( { auth : value } )
21
-
22
- // const oct = getOctokit()
23
- // const rr = await oct.actions.getRepoPublicKey({
24
- // ...github.context.repo,
25
- // })
26
-
27
- // core.info(`RR: ${JSON.stringify(rr, null, 2)}`)
28
-
29
- // Get publick key
30
- const ret = await oct . request (
14
+ const res = await octokit . request (
31
15
'GET /repos/:owner/:repo/actions/secrets/public-key' ,
32
16
repo ,
33
17
)
34
18
35
- core . info ( `Ret: ${ JSON . stringify ( ret , null , 2 ) } ` )
36
-
37
- const res = await octokit . actions . getRepoPublicKey ( {
38
- ...github . context . repo ,
39
- } )
40
19
const key = res . data . key
41
20
42
- core . info ( `Key: ${ JSON . stringify ( res . data , null , 2 ) } ` )
43
-
44
21
// Convert the message and key to Uint8Array's
45
22
const messageBytes = Buffer . from ( value )
46
23
const keyBytes = Buffer . from ( key , 'base64' )
@@ -56,19 +33,23 @@ export namespace Util {
56
33
}
57
34
58
35
export async function createOrUpdateRepoSecret (
59
- octokit : ReturnType < typeof github . getOctokit > ,
36
+ token : string ,
60
37
name : string ,
61
38
value : string ,
62
39
) {
63
40
try {
41
+ const octokit = new Octokit ( { auth : token } )
64
42
const secret = await createSecret ( octokit , value )
65
43
core . info ( `created secret: ${ JSON . stringify ( secret , null , 2 ) } ` )
66
44
67
- await octokit . actions . createOrUpdateRepoSecret ( {
68
- ...github . context . repo ,
69
- ...secret ,
70
- secret_name : name ,
71
- } )
45
+ await octokit . request (
46
+ 'PUT /repos/:owner/:repo/actions/secrets/:secret_name' ,
47
+ {
48
+ ...github . context . repo ,
49
+ secret_name : name ,
50
+ data : secret ,
51
+ } ,
52
+ )
72
53
} catch ( e ) {
73
54
core . error ( e )
74
55
core . error ( JSON . stringify ( e , null , 2 ) )
0 commit comments