File tree Expand file tree Collapse file tree 3 files changed +49
-3
lines changed
Expand file tree Collapse file tree 3 files changed +49
-3
lines changed Original file line number Diff line number Diff line change 1+ import { Octokit } from "@octokit/rest" ;
2+ import { createAppAuth } from "@octokit/auth-app"
3+
4+ export const getAccessToken = async ( ) => {
5+
6+ const { GITHUB_APP_ID , GITHUB_APP_PRIVATE_KEY } = process . env
7+
8+ const octoKitInstance = new Octokit ( {
9+ authStrategy : createAppAuth ,
10+ auth : {
11+ appId : GITHUB_APP_ID ,
12+ privateKey : GITHUB_APP_PRIVATE_KEY
13+ }
14+ } ) ;
15+
16+ const { data : installations } = await octoKitInstance . rest . apps . listInstallations ( )
17+
18+ console . log ( "installations -----" , installations ) ;
19+
20+
21+ if ( ! installations . length ) {
22+ throw new Error ( "No Installations found for this github app" )
23+ }
24+
25+ const installationId = installations [ 0 ] . id ;
26+
27+ const installationAccessToken = await octoKitInstance . rest . apps . createInstallationAccessToken ( { installation_id : installationId } )
28+
29+ return installationAccessToken . data . token
30+ }
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " xero-octokit" ,
3+ "version" : " 1.0.0" ,
4+ "description" : " " ,
5+ "main" : " index.js" ,
6+ "type" : " module" ,
7+ "scripts" : {
8+ "test" : " echo \" Error: no test specified\" && exit 1"
9+ },
10+ "author" : " " ,
11+ "license" : " ISC" ,
12+ "dependencies" : {
13+ "@octokit/auth-app" : " ^7.1.1" ,
14+ "@octokit/rest" : " ^21.0.2"
15+ }
16+ }
Original file line number Diff line number Diff line change @@ -119,8 +119,8 @@ jobs:
119119 - name : Checkout
120120 uses : actions/checkout@v4
121121 with :
122- repository : XeroAPI/xero-node
123- path : xero-node
122+ repository : XeroAPI/xero-python
123+ path : xero-python
124124
125125 - name : Install octokit dependencies
126126 run : npm i
@@ -146,7 +146,7 @@ jobs:
146146 -H "Content-Type: application/json" \
147147 https://api.github.com/repos/xero-internal/xeroapi-sdk-codegen/actions/workflows/notify-sdk-publish.yml/dispatches \
148148 -d '{
149- "ref": "deploy-track-pipeline-changes ",
149+ "ref": "master ",
150150 "inputs": {
151151 "commit": "${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}",
152152 "status": "${{needs.publish.result}}",
You can’t perform that action at this time.
0 commit comments