Skip to content

Commit dcee983

Browse files
author
sangeet-joy_xero
committed
added octokit
1 parent c6f42f2 commit dcee983

File tree

3 files changed

+49
-4
lines changed

3 files changed

+49
-4
lines changed

.github/octokit/index.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
}

.github/octokit/package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
}

.github/workflows/publish.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ jobs:
101101
button_type: "danger"
102102
package_version: ${{needs.publish.outputs.release_number}}
103103
repo_link: ${{github.server_url}}/${{github.repository}}
104-
105104
notify-codegen-repo:
106105
needs: publish
107106
if: always()
@@ -114,8 +113,8 @@ jobs:
114113
- name: Checkout
115114
uses: actions/checkout@v4
116115
with:
117-
repository: XeroAPI/xero-node
118-
path: xero-node
116+
repository: XeroAPI/xero-ruby
117+
path: xero-ruby
119118

120119
- name: Install octokit dependencies
121120
run: npm i
@@ -141,7 +140,7 @@ jobs:
141140
-H "Content-Type: application/json" \
142141
https://api.github.com/repos/xero-internal/xeroapi-sdk-codegen/actions/workflows/notify-sdk-publish.yml/dispatches \
143142
-d '{
144-
"ref": "deploy-track-pipeline-changes",
143+
"ref": "master",
145144
"inputs": {
146145
"commit": "${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}",
147146
"status": "${{needs.publish.result}}",

0 commit comments

Comments
 (0)