Skip to content

Commit b7be56e

Browse files
committed
- delete and lock actions triggered for the whole pull request not for every component
1 parent 081ae77 commit b7be56e

File tree

1 file changed

+24
-38
lines changed

1 file changed

+24
-38
lines changed

index.js

Lines changed: 24 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -246,22 +246,15 @@ const getDeletePayloads = async (context, { owner, repo, pullNumber, sha }) => {
246246
return [];
247247
}
248248

249-
const charts = deploy.components
250-
.map(({ name }) => ({ name }));
251-
252-
return charts.reduce(async (acc, { name }) => {
253-
const val = await acc;
254-
const description = `Delete ${name} for ${repo}/pull/${pullNumber}`;
255-
const environment = `${repo.replace('.', '-')}-pull-${pullNumber}`;
256-
return [...val, {
257-
repo,
258-
component: name.replace('.', '-'),
259-
description,
260-
environment,
261-
domain: `${environment}.${domain}`,
262-
action: 'delete',
263-
}];
264-
}, Promise.resolve([]));
249+
const description = `Delete ${repo}/pull/${pullNumber}`;
250+
const environment = `${repo.replace('.', '-')}-pull-${pullNumber}`;
251+
return [{
252+
repo,
253+
description,
254+
environment,
255+
domain: `${environment}.${domain}`,
256+
action: 'delete',
257+
}];
265258
}
266259

267260
const getLockPayloads = async (context, { owner, repo, pullNumber, sha }) => {
@@ -273,22 +266,15 @@ const getLockPayloads = async (context, { owner, repo, pullNumber, sha }) => {
273266
return [];
274267
}
275268

276-
const charts = deploy.components
277-
.map(({ name }) => ({ name }));
278-
279-
return charts.reduce(async (acc, { name }) => {
280-
const val = await acc;
281-
const description = `Lock ${name} for ${repo}/pull/${pullNumber}`;
282-
const environment = `${repo.replace('.', '-')}-pull-${pullNumber}`;
283-
return [...val, {
284-
repo,
285-
component: name.replace('.', '-'),
286-
description,
287-
environment,
288-
domain: `${environment}.${domain}`,
289-
action: 'lock',
290-
}];
291-
}, Promise.resolve([]));
269+
const description = `Lock ${repo}/pull/${pullNumber}`;
270+
const environment = `${repo.replace('.', '-')}-pull-${pullNumber}`;
271+
return [{
272+
repo,
273+
description,
274+
environment,
275+
domain: `${environment}.${domain}`,
276+
action: 'lock',
277+
}];
292278
}
293279

294280
const createDeployments = async (app, context, owner, payloads) => {
@@ -314,8 +300,8 @@ const createDeployments = async (app, context, owner, payloads) => {
314300
};
315301

316302
const deleteDeployments = async (app, context, owner, payloads) => {
317-
await bluebird.mapSeries(payloads, async ({ repo, component, environment, description, domain, action }) => {
318-
app.log.info({ repo, component, environment, description, domain, action });
303+
await bluebird.mapSeries(payloads, async ({ repo, environment, description, domain, action }) => {
304+
app.log.info({ repo, environment, description, domain, action });
319305
const res = await context.octokit.repos.createDeployment({
320306
owner: owner,
321307
repo: 'charts',
@@ -324,7 +310,7 @@ const deleteDeployments = async (app, context, owner, payloads) => {
324310
auto_merge: false, // Attempts to automatically merge the default branch into the requested ref, if it is behind the default branch.
325311
required_contexts: [], // The status contexts to verify against commit status checks. If this parameter is omitted, then all unique contexts will be verified before a deployment is created. To bypass checking entirely pass an empty array. Defaults to all unique contexts.
326312
payload: {
327-
repo, component, domain, action, environment,
313+
repo, domain, action, environment,
328314
}, // JSON payload with extra information about the deployment. Default: ""
329315
environment, // Name for the target deployment environment (e.g., production, staging, qa)
330316
description, // Short description of the deployment
@@ -358,8 +344,8 @@ const deleteDeployments = async (app, context, owner, payloads) => {
358344
};
359345

360346
const lockDeployments = async (app, context, owner, payloads) => {
361-
await bluebird.mapSeries(payloads, async ({ repo, component, environment, description, domain, action }) => {
362-
app.log.info({ repo, component, environment, description, domain, action });
347+
await bluebird.mapSeries(payloads, async ({ repo, environment, description, domain, action }) => {
348+
app.log.info({ repo, environment, description, domain, action });
363349
const res = await context.octokit.repos.createDeployment({
364350
owner: owner,
365351
repo: 'charts',
@@ -368,7 +354,7 @@ const lockDeployments = async (app, context, owner, payloads) => {
368354
auto_merge: false, // Attempts to automatically merge the default branch into the requested ref, if it is behind the default branch.
369355
required_contexts: [], // The status contexts to verify against commit status checks. If this parameter is omitted, then all unique contexts will be verified before a deployment is created. To bypass checking entirely pass an empty array. Defaults to all unique contexts.
370356
payload: {
371-
repo, component, domain, action, environment,
357+
repo, domain, action, environment,
372358
}, // JSON payload with extra information about the deployment. Default: ""
373359
environment, // Name for the target deployment environment (e.g., production, staging, qa)
374360
description, // Short description of the deployment

0 commit comments

Comments
 (0)