fix: order of checks in setGithubToken (#382)

- Fixes #358
- Related #359
This commit is contained in:
Sarisia 2020-07-09 04:26:02 +09:00 committed by GitHub
parent c6333d41f0
commit 31cdbe5222
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -70,6 +70,10 @@ export function setGithubToken(
core.debug(`eventName: ${eventName}`); core.debug(`eventName: ${eventName}`);
let isProhibitedBranch = false; let isProhibitedBranch = false;
if (externalRepository) {
throw new Error('GITHUB_TOKEN does not support to push to an external repository');
}
if (eventName === 'push') { if (eventName === 'push') {
isProhibitedBranch = ref.includes(`refs/heads/${publishBranch}`); isProhibitedBranch = ref.includes(`refs/heads/${publishBranch}`);
if (isProhibitedBranch) { if (isProhibitedBranch) {
@ -77,10 +81,6 @@ export function setGithubToken(
} }
} }
if (externalRepository) {
throw new Error('GITHUB_TOKEN does not support to push to an external repository');
}
return `https://x-access-token:${githubToken}@github.com/${publishRepo}.git`; return `https://x-access-token:${githubToken}@github.com/${publishRepo}.git`;
} }