Skip to content

Commit

Permalink
adjust to check triggering event instead of contents of pull_request
Browse files Browse the repository at this point in the history
  • Loading branch information
electrofelix authored and chinthakagodawita committed Apr 17, 2021
1 parent c224f42 commit c9bf13c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
20 changes: 11 additions & 9 deletions src/autoupdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,25 @@ export class AutoUpdater {
async handleWorkflowRun(): Promise<number> {
const { workflow_run, repository } = this.eventData;
const branch = workflow_run.head_branch;
const event = workflow_run.event;

if (workflow_run.event !== 'push') {
ghCore.warning(
`Workflow_run event triggered via ${event} workflow not yet supported.`,
);
return 0;
}

// this may not be possible given the check above, but leaving in for now
if (branch.length === 0) {
ghCore.warning('Push event was not on a branch, skipping.');
ghCore.warning('Event was not on a branch, skipping.');
return 0;
}

ghCore.info(
`Handling workflow-run event triggered by '${workflow_run.event}' on '${branch}'`,
`Handling workflow-run event triggered by '${event}' on '${branch}'`,
);

if (workflow_run.pull_requests.length !== 0) {
ghCore.warning(
'Workflow_run event triggered via pull_request workflow not yet supported.',
);
return 0;
}

const updated = await this.pulls(`refs/heads/${branch}`, repository);

return updated;
Expand Down
7 changes: 1 addition & 6 deletions test/autoupdate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -559,12 +559,7 @@ describe('test `handleWorkflowRun`', () => {

test('workflow_run event by pull_request event not supported', async () => {
const event = cloneEvent();
event.workflow_run.pull_requests = [
{
url: 'https://api.github.com/repos/github/hello-world/pulls/1',
id: 1,
},
];
event.workflow_run.event = 'pull_request';

const updater = new AutoUpdater(config, event);

Expand Down

0 comments on commit c9bf13c

Please sign in to comment.