2022-01-13 13:00:31 +00:00
|
|
|
/*******************************
|
|
|
|
GitHub Login
|
|
|
|
*******************************/
|
|
|
|
/*
|
|
|
|
Logs into GitHub using OAuth
|
|
|
|
*/
|
|
|
|
|
2023-08-17 09:47:40 +00:00
|
|
|
const
|
|
|
|
fs = require('fs'),
|
|
|
|
path = require('path'),
|
|
|
|
GithubAPI = require('@octokit/rest'),
|
2022-01-13 13:00:31 +00:00
|
|
|
|
2023-08-17 09:47:40 +00:00
|
|
|
// stores oauth info for GitHub API
|
|
|
|
oAuth = fs.existsSync(path.join(__dirname, './oauth.js'))
|
|
|
|
? require('./oauth.js') // eslint-disable-line import/extensions
|
|
|
|
: false
|
2022-01-13 13:00:31 +00:00
|
|
|
;
|
|
|
|
|
2023-08-17 09:47:40 +00:00
|
|
|
if (!oAuth) {
|
|
|
|
console.error('Must add oauth token for GitHub in tasks/config/admin/oauth.js');
|
2022-01-13 13:00:31 +00:00
|
|
|
}
|
|
|
|
|
2023-08-17 09:47:40 +00:00
|
|
|
let github = new GithubAPI({
|
|
|
|
version: '3.0.0',
|
|
|
|
debug: true,
|
|
|
|
protocol: 'https',
|
|
|
|
timeout: 5000,
|
2022-01-13 13:00:31 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
github.authenticate({
|
2023-08-17 09:47:40 +00:00
|
|
|
type: 'oauth',
|
|
|
|
token: oAuth.token,
|
2022-01-13 13:00:31 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = github;
|