Skip to content

Commit 72b007c

Browse files
committed
fetchreleases will now ask for the GitHub access Token at runtime
Instead of storing the token in an environment variable (which is a security risk) the script asks for the token at runtime. Note: better yet would be using the GitHub CLI to authenticate.
1 parent c16d62f commit 72b007c

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

scripts/fetchReleases.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
const readline = require('readline');
12
const { graphql } = require('@octokit/graphql');
23
const fs = require('fs');
34
const path = require('path');
45

5-
const fetchReleases = async () => {
6+
const fetchReleases = async (githubToken) => {
67
const { processing, processing4 } = await graphql(
78
`
89
query {
@@ -48,7 +49,7 @@ const fetchReleases = async () => {
4849
`,
4950
{
5051
headers: {
51-
authorization: `token ${process.env.GITHUB_TOKEN}`
52+
authorization: `token ${githubToken}`
5253
}
5354
}
5455
);
@@ -71,10 +72,14 @@ const fetchReleases = async () => {
7172
});
7273
};
7374

74-
// only fetch if ENV has GITHUB_TOKEN
75-
if (process.env.GITHUB_TOKEN) {
75+
const rl = readline.createInterface({
76+
input: process.stdin,
77+
output: process.stdout
78+
});
79+
80+
rl.question('Please enter your GitHub token: ', (token) => {
81+
rl.close();
82+
7683
console.log('Fetching releases from github.com');
77-
fetchReleases();
78-
} else {
79-
console.log('No GitHub token found. Bypassing fetch of releases');
80-
}
84+
fetchReleases(token);
85+
});

0 commit comments

Comments
 (0)