Use GITHUB_TOKEN for API requests

This commit is contained in:
Yuri Sizov
2021-09-06 13:21:28 +03:00
parent 16a8cd92fb
commit 5bd63ff8ce
2 changed files with 5 additions and 0 deletions

View File

@@ -34,6 +34,8 @@ jobs:
- name: Fetch pull request data
run: npm run compose-db
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy to GitHub Pages 🚀
uses: JamesIves/github-pages-deploy-action@releases/v3

View File

@@ -22,6 +22,9 @@ async function fetchGithub(url) {
const init = {};
init.headers = {};
init.headers["Accept"] = "application/vnd.github.v3+json";
if (process.env.GITHUB_TOKEN) {
init.headers["Authorization"] = `token ${process.env.GITHUB_TOKEN}`;
}
return await fetch(`https://api.github.com${url}`, init);
}