1
0
mirror of synced 2025-12-19 18:10:59 -05:00
Files
docs/script/helpers/github.js
Grace Park d3d1902414 Merge pull request #20017 from github/upgrade-esm
Enforce and Move to Top Level require
2021-06-22 11:27:48 -07:00

23 lines
619 B
JavaScript

const dotenv = require('dotenv')
if (!process.env.GITHUB_TOKEN) {
dotenv.config()
}
// this module needs to work in development, production, and GitHub Actions
//
// GITHUB_TOKEN comes from one of the following sources:
// 1. set in the .env file (development)
// 2. set as a Heroku config var (staging and production)
// 3. an installation token granted via GitHub Actions
const apiToken = process.env.GITHUB_TOKEN
const { Octokit } = require('@octokit/rest')
// See https://github.com/octokit/rest.js/issues/1207
module.exports = function github () {
return new Octokit({
auth: `token ${apiToken}`
})
}