Skip to content

Commit

Permalink
Skip deployments of updated github PR with only body changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rocketeerbkw committed Jan 29, 2019
1 parent e827717 commit 70ab1b8
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
// @flow

const R = require('ramda');
const { logger } = require('@lagoon/commons/src/local-logging');
const { sendToLagoonLogs } = require('@lagoon/commons/src/logs');
const { createDeployTask } = require('@lagoon/commons/src/tasks');

import type { WebhookRequestData, removeData, ChannelWrapper, Project } from '../types';

const isEditAction = R.propEq('action', 'edited');

const onlyBodyChanges = R.pipe(
R.propOr({}, 'changes'),
R.keys,
R.equals(['body']),
);

const skipRedeploy = R.and(isEditAction, onlyBodyChanges);

async function githubPullRequestSynchronize(webhook: WebhookRequestData, project: Project) {

const {
Expand All @@ -16,9 +27,12 @@ async function githubPullRequestSynchronize(webhook: WebhookRequestData, project
body,
} = webhook;

if (body.action == 'updated' && !('base' in body.changes)) {
// we are only interested in this webhook if the base had been updated, ofter updates like title or description don't need a redeploy
return
// Don't trigger deploy if only the PR body was edited.
if (skipRedeploy(body)) {
sendToLagoonLogs('info', project.name, uuid, `${webhooktype}:${event}:handledButNoTask`, {},
`*[${project.name}]* PR ${body.number} updated. No deploy task created, reason: Only body changed`
)
return;
}

const headBranchName = body.pull_request.head.ref
Expand Down

0 comments on commit 70ab1b8

Please sign in to comment.