forked from chriskinsman/github-action-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetinstallationid.js
More file actions
29 lines (26 loc) · 915 Bytes
/
getinstallationid.js
File metadata and controls
29 lines (26 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require('dotenv').config()
const { createAppAuth } = require("@octokit/auth-app");
const { Octokit } = require("@octokit/rest");
const _appId = process.env.GITHUB_APPID;
// Handles newlines \n in private key
const _privateKey = Buffer.from(process.env.GITHUB_APP_PRIVATEKEY || "", "base64").toString("utf-8");
const _clientId = process.env.GITHUB_APP_CLIENTID;
const _clientSecret = process.env.GITHUB_APP_CLIENTSECRET;
const octokit = new Octokit({
auth: {
appId: _appId,
privateKey: _privateKey,
clientId: _clientId,
clientSecret: _clientSecret,
},
authStrategy: createAppAuth
});
octokit.apps.listInstallations()
.then(response => {
response.data.forEach((installation) => {
console.log(`Account: ${installation.account.login}, installation id: ${installation.id}`);
});
})
.catch(err => {
console.error(err);
});