File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 1818 - run :
1919 name : Updating schema
2020 command : |
21+ git clone "https://x-access-token:$(./scripts/github_token.js 290530)@github.com/heroku/typescript-api-schema.git" repo
22+ cd repo
2123 git config --global push.default simple
2224 git config --global user.name "$GIT_AUTHOR_NAME"
2325 git config --global user.email "$GIT_AUTHOR_EMAIL"
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env node
2+
3+ // gets a github auth token for a github app
4+
5+ const jwt = require ( 'jsonwebtoken' )
6+ const { HTTP } = require ( 'http-call' )
7+ const exp = new Date ( )
8+ exp . setMinutes ( exp . getMinutes ( ) + 10 )
9+ const env = k => {
10+ if ( process . env [ k ] ) return process . env [ k ]
11+ else throw new Error ( `Must set ${ k } ` )
12+ }
13+
14+ const token = jwt . sign ( {
15+ // iss: env('GITHUB_APP_ID')
16+ } , env ( 'GITHUB_APP_PEM' ) , {
17+ issuer : env ( 'GITHUB_APP_ID' ) ,
18+ algorithm : 'RS256' ,
19+ expiresIn : '10m'
20+ } )
21+
22+ const installation = process . argv [ 2 ]
23+
24+ async function run ( ) {
25+ const { body} = await HTTP . post ( `https://api.github.com/app/installations/${ installation } /access_tokens` , {
26+ headers : {
27+ Authorization : `Bearer ${ token } ` ,
28+ Accept : 'application/vnd.github.machine-man-preview+json"'
29+ }
30+ } )
31+ console . log ( body . token )
32+ }
33+
34+ run ( )
35+ . catch ( err => {
36+ console . error ( err )
37+ process . exit ( 1 )
38+ } )
You can’t perform that action at this time.
0 commit comments