Update hard-coded GitHub URLs to be dynamic

Set the following environment variables to override the defaults:

REPO_OWNER            (default: 'atom')
MAIN_REPO             (default: 'atom')
NIGHLTY_RELEASE_REPO  (default: 'atom-nightly-releases')

Co-Authored-By: DeeDeeG <DeeDeeG@users.noreply.github.com>
This commit is contained in:
Amin Yahyaabadi 2020-09-16 01:29:10 -05:00
parent 5f35bd0bd9
commit f15eefb147
3 changed files with 14 additions and 5 deletions

View File

@ -7,6 +7,9 @@ const path = require('path');
const CONFIG = require('../config');
const REPO_OWNER = process.env.REPO_OWNER || 'atom';
const MAIN_REPO = process.env.MAIN_REPO || 'atom';
module.exports = packagedAppPath => {
const archSuffix = process.arch === 'ia32' ? '' : '-' + process.arch;
const updateUrlPrefix =
@ -17,7 +20,7 @@ module.exports = packagedAppPath => {
exe: CONFIG.executableName,
appDirectory: packagedAppPath,
authors: 'GitHub Inc.',
iconUrl: `https://raw.githubusercontent.com/atom/atom/master/resources/app-icons/${
iconUrl: `https://raw.githubusercontent.com/${REPO_OWNER}/${MAIN_REPO}/master/resources/app-icons/${
CONFIG.channel
}/atom.ico`,
loadingGif: path.join(

View File

@ -1,3 +1,6 @@
const REPO_OWNER = process.env.REPO_OWNER || 'atom';
const MAIN_REPO = process.env.MAIN_REPO || 'atom';
const git = (git, repositoryRootPath) => {
const path = require('path');
const packageJsonFilePath = path.join(repositoryRootPath, 'package.json');
@ -10,7 +13,7 @@ const git = (git, repositoryRootPath) => {
if (!err && !remotes.map(({ name }) => name).includes('ATOM')) {
git.addRemote(
'ATOM',
`https://atom:${process.env.AUTH_TOKEN}@github.com/atom/atom.git/`
`https://atom:${process.env.AUTH_TOKEN}@github.com/${REPO_OWNER}/${MAIN_REPO}.git/`
);
}
});

View File

@ -1,13 +1,16 @@
const { request } = require('@octokit/request');
const REPO_OWNER = process.env.REPO_OWNER || 'atom';
const MAIN_REPO = process.env.MAIN_REPO || 'atom';
const requestWithAuth = request.defaults({
baseUrl: 'https://api.github.com',
headers: {
'user-agent': 'atom',
authorization: `token ${process.env.AUTH_TOKEN}`
},
owner: 'atom',
repo: 'atom'
owner: REPO_OWNER,
repo: MAIN_REPO
});
module.exports = {
@ -28,7 +31,7 @@ module.exports = {
},
findPR: async ({ moduleName, latest }, branch) => {
return requestWithAuth('GET /search/issues', {
q: `${moduleName} type:pr ${moduleName}@${latest} in:title repo:atom/atom head:${branch} state:open`
q: `${moduleName} type:pr ${moduleName}@${latest} in:title repo:${REPO_OWNER}/${MAIN_REPO} head:${branch} state:open`
});
},
addLabel: async pullRequestNumber => {