Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Add additional validation
  • Loading branch information
n1hility committed Feb 4, 2020
1 parent db63ce1 commit 6595731233df96cc183f56db9db19a4313e7febf
Showing 2 changed files with 28 additions and 6 deletions.
@@ -1472,14 +1472,24 @@ function run() {
const token = core.getInput('token');
const selfRunId = getRequiredEnv('GITHUB_RUN_ID');
const repository = getRequiredEnv('GITHUB_REPOSITORY');
const eventName = getRequiredEnv('GITHUB_EVENT_NAME');
const [owner, repo] = repository.split('/');
const refsPrefix = 'refs/heads/';
const branchPrefix = 'refs/heads/';
const tagPrefix = 'refs/tags/';
if (eventName !== 'push') {
core.info('Skipping non-push event');
return;
}
let branch = getRequiredEnv('GITHUB_REF');
if (!branch.startsWith(refsPrefix)) {
if (!branch.startsWith(branchPrefix)) {
if (branch.startsWith(tagPrefix)) {
core.info(`Skipping tag build`);
return;
}
const message = `${branch} was not an expected branch ref (refs/heads/).`;
throw new Error(message);
}
branch = branch.replace(refsPrefix, '');
branch = branch.replace(branchPrefix, '');
core.info(`Branch is ${branch}, repo is ${repo}, and owner is ${owner}, and id is ${selfRunId}`);
const octokit = new github.GitHub(token);
const listRuns = octokit.actions.listRepoWorkflowRuns.endpoint.merge({
@@ -7,15 +7,27 @@ async function run(): Promise<void> {

const selfRunId = getRequiredEnv('GITHUB_RUN_ID')
const repository = getRequiredEnv('GITHUB_REPOSITORY')
const eventName = getRequiredEnv('GITHUB_EVENT_NAME')

const [owner, repo] = repository.split('/')
const refsPrefix = 'refs/heads/'
const branchPrefix = 'refs/heads/'
const tagPrefix = 'refs/tags/'

if (eventName !== 'push') {
core.info('Skipping non-push event')
return
}

let branch = getRequiredEnv('GITHUB_REF')
if (!branch.startsWith(refsPrefix)) {
if (!branch.startsWith(branchPrefix)) {
if (branch.startsWith(tagPrefix)) {
core.info(`Skipping tag build`)
return
}
const message = `${branch} was not an expected branch ref (refs/heads/).`
throw new Error(message)
}
branch = branch.replace(refsPrefix, '')
branch = branch.replace(branchPrefix, '')

core.info(
`Branch is ${branch}, repo is ${repo}, and owner is ${owner}, and id is ${selfRunId}`

0 comments on commit 6595731

Please sign in to comment.