From 0afcf5be697cab4c3ce981a499ce68c030db4219 Mon Sep 17 00:00:00 2001 From: Paul Sauve Date: Wed, 28 Jun 2017 16:31:12 -0500 Subject: [PATCH] Fix authentication --- scripts/travis-bench.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/travis-bench.js b/scripts/travis-bench.js index 0f46b8639c..6670a94123 100644 --- a/scripts/travis-bench.js +++ b/scripts/travis-bench.js @@ -79,8 +79,11 @@ try { const githubUsername = 'Svelte-Bot'; const id = 29757693; const githubToken = process.env.GITHUB_ACCESS_TOKEN; +const headers = { + Authorization: `token ${githubToken}` +}; -fetch(`https://${githubUsername}:${githubToken}@api.github.com/repos/sveltejs/svelte/issues/${pullRequest}/comments`) +fetch(`https://api.github.com/repos/sveltejs/svelte/issues/${pullRequest}/comments`, { headers }) .then(res => res.json()) .then(res => { let addComment = false; @@ -96,15 +99,17 @@ fetch(`https://${githubUsername}:${githubToken}@api.github.com/repos/sveltejs/sv if (addComment) { const contents = '
Benchmark Results' + fs.readFileSync(outputFile) + '
'; if (editId === null) { - return fetch(`https://${githubUsername}:${githubToken}@api.github.com/repos/sveltejs/svelte/issues/${pullRequest}/comments`, { + return fetch(`https://api.github.com/repos/sveltejs/svelte/issues/${pullRequest}/comments`, { method: 'POST', + headers, body: JSON.stringify({ body: contents }) }); } else { - return fetch(`https://${githubUsername}:${githubToken}@api.github.com/repos/sveltejs/svelte/issues/comments/${editId}`, { + return fetch(`https://api.github.com/repos/sveltejs/svelte/issues/comments/${editId}`, { method: 'PATCH', + headers, body: JSON.stringify({ body: contents })