From 2a39fd1b0230ee83a31573c0eddb70fc4efdcb41 Mon Sep 17 00:00:00 2001 From: Cyril Lakech <1169286+clakech@users.noreply.github.com> Date: Tue, 25 Feb 2020 13:39:10 +0100 Subject: [PATCH] feat: auth github request using env variable --- src/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index ffb02b3..b2ad697 100644 --- a/src/index.ts +++ b/src/index.ts @@ -31,7 +31,9 @@ const matchGithub = (url: string | undefined, prop: string) => { const getRangeFromPr = async () => { const {owner, repo, data: pull} = matchGithub(process.env['CIRCLE_PULL_REQUEST'], 'pull') const github = new Octokit() - + if (process.env.GITHUB_TOKEN) + github.authenticate({ type: 'token', token: process.env.GITHUB_TOKEN || '' }) + console.log('📡 Looking up PR #%s...', pull) const {data: {base, head}} = await github.pullRequests.get( {owner, repo, number: +pull}