Skip to content

Commit

Permalink
feat: add support for github authentication
Browse files Browse the repository at this point in the history
Authentication is required to bypass the Github rate limiting.
  • Loading branch information
MoritzWeber0 committed Sep 1, 2022
1 parent 5c57aab commit 1487cfd
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion frontend/fetch-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,25 @@ const { writeFileSync } = require('fs');
const util = require('node:util');
const exec = util.promisify(require('node:child_process').exec);

let options = {};

if (process.env.http_proxy) {
const { setGlobalDispatcher, ProxyAgent } = require('undici');

setGlobalDispatcher(new ProxyAgent(process.env.http_proxy));
}

if (process.env.GITHUB_USERNAME && process.env.GITHUB_TOKEN) {
console.error('Using credentials from environment variables.');
options.headers = {
Authorization:
'Basic ' +
Buffer.from(
process.env.GITHUB_USERNAME + ':' + process.env.GITHUB_TOKEN
).toString('base64'),
};
}

async function main() {
const git = exec('git describe --tags', {
cwd: __dirname,
Expand All @@ -22,7 +35,8 @@ async function main() {
});

const github = fetch(
'https://api.github.com/repos/DSD-DBS/capella-collab-manager/releases'
'https://api.github.com/repos/DSD-DBS/capella-collab-manager/releases',
options
);

const gitResponse = await git;
Expand Down

0 comments on commit 1487cfd

Please sign in to comment.