mirror of
https://github.com/godotengine/godot-team-reports.git
synced 2026-09-03 23:39:52 +03:00
Use custom access tokens for GitHub API
This commit is contained in:
1
.github/workflows/ci.yml
vendored
1
.github/workflows/ci.yml
vendored
@@ -36,6 +36,7 @@ jobs:
|
|||||||
- name: Fetch pull request data
|
- name: Fetch pull request data
|
||||||
run: npm run compose-db
|
run: npm run compose-db
|
||||||
env:
|
env:
|
||||||
|
GRAPHQL_TOKEN: ${{ secrets.GRAPHQL_TOKEN }}
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Archive production artifacts
|
- name: Archive production artifacts
|
||||||
|
|||||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -1,3 +1,8 @@
|
|||||||
|
# Project folders.
|
||||||
node_modules/
|
node_modules/
|
||||||
out/
|
out/
|
||||||
|
logs/
|
||||||
|
|
||||||
|
# Development environments.
|
||||||
.idea/
|
.idea/
|
||||||
|
.vscode/
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ should work just fine).
|
|||||||
|
|
||||||
This project uses GitHub's GraphQL API. To fetch live data you need to generate
|
This project uses GitHub's GraphQL API. To fetch live data you need to generate
|
||||||
a [personal OAuth token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token).
|
a [personal OAuth token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token).
|
||||||
You can supply your token to the scripts using the `GITHUB_TOKEN` environment
|
You can supply your token to the scripts using the `GRAPHQL_TOKEN` environment
|
||||||
variable. Note, that if you don't have member access to the organization, you
|
variable. Note, that if you don't have member access to the organization, you
|
||||||
may not be able to access all the information used when generating the database.
|
may not be able to access all the information used when generating the database.
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,9 @@ async function fetchGithub(query) {
|
|||||||
init.headers = {};
|
init.headers = {};
|
||||||
init.headers["Content-Type"] = "application/json";
|
init.headers["Content-Type"] = "application/json";
|
||||||
init.headers["Accept"] = "application/vnd.github.merge-info-preview+json";
|
init.headers["Accept"] = "application/vnd.github.merge-info-preview+json";
|
||||||
if (process.env.GITHUB_TOKEN) {
|
if (process.env.GRAPHQL_TOKEN) {
|
||||||
|
init.headers["Authorization"] = `token ${process.env.GRAPHQL_TOKEN}`;
|
||||||
|
} else if (process.env.GITHUB_TOKEN) {
|
||||||
init.headers["Authorization"] = `token ${process.env.GITHUB_TOKEN}`;
|
init.headers["Authorization"] = `token ${process.env.GITHUB_TOKEN}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,6 +49,14 @@ async function fetchGithub(query) {
|
|||||||
return await fetch("https://api.github.com/graphql", init);
|
return await fetch("https://api.github.com/graphql", init);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function logResponse(data, name) {
|
||||||
|
try {
|
||||||
|
await fs.writeFile(`logs/${name}.json`, JSON.stringify(data, null, 4), {encoding: "utf-8"});
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Error saving log file: " + err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function handleErrors(data) {
|
function handleErrors(data) {
|
||||||
if (typeof data["errors"] === "undefined") {
|
if (typeof data["errors"] === "undefined") {
|
||||||
return;
|
return;
|
||||||
@@ -88,6 +98,7 @@ async function checkRates() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
|
logResponse(data, "_rate_limit");
|
||||||
handleErrors(data);
|
handleErrors(data);
|
||||||
|
|
||||||
const rate_limit = data.data["rateLimit"];
|
const rate_limit = data.data["rateLimit"];
|
||||||
@@ -201,6 +212,7 @@ async function fetchPulls(page) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
|
logResponse(data, `data_page_${page}`);
|
||||||
handleErrors(data);
|
handleErrors(data);
|
||||||
|
|
||||||
const rate_limit = data.data["rateLimit"];
|
const rate_limit = data.data["rateLimit"];
|
||||||
|
|||||||
Reference in New Issue
Block a user