Skip to content

Commit

Permalink
Update the start.js script
Browse files Browse the repository at this point in the history
  • Loading branch information
ZPascal committed Feb 13, 2022
1 parent 054458d commit 65a6c26
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion start.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,23 @@ const trim = (value, charlist) => trimLeft(trimRight(value, charlist));
const main = async () => {
let branch = process.env.INPUT_BRANCH;
const repository = trim(process.env.INPUT_REPOSITORY || process.env.GITHUB_REPOSITORY);
const github_url = trim(process.env.INPUT_GITHUB_URL)
if (!branch) {
const headers = {
'User-Agent': 'github.com/ad-m/github-push-action'
};
if (process.env.INPUT_GITHUB_TOKEN) headers.Authorization = `token ${process.env.INPUT_GITHUB_TOKEN}`;
const body = JSON.parse(await get(`https://api.github.com/repos/${repository}`, { headers }))
let api_url = 'api.github.com';
if (github_url !== 'github.com') api_url = github_url + '/api/v3';
const body = JSON.parse(await get(`https://${api_url}/repos/${repository}`, { headers }))
branch = body.default_branch;
}
await exec('bash', [path.join(__dirname, './start.sh')], {
env: {
...process.env,
INPUT_BRANCH: branch,
INPUT_REPOSITORY: repository,
INPUT_GITHUB_URL: github_url,
}
});
};
Expand Down

0 comments on commit 65a6c26

Please sign in to comment.