mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[cft] Support persisting deployments (#144370)
Adds support for a label `ci:cloud-persist-deployment`, that will prevent deployments from shutting down until the label is removed. This also fixes a bug in the conditional checking for whether the cloud deployment label was removed. If `ci:cloud-deploy` is removed from a PR, the deployment should now shutdown in the next hour instead of after 48h. It's easiest to test this after merging. I can alternatively modify the pipeline to run on a branch, but either way I'll end up pushing commits and this is fairly straight forward and it breaking is low risk. Either way works for me. Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Tyler Smalley <tylersmalley@gmail.com>
This commit is contained in:
parent
49a18f121e
commit
5f342636d2
1 changed files with 13 additions and 3 deletions
|
@ -25,16 +25,26 @@ for (const deployment of prDeployments) {
|
|||
const prNumber = deployment.name.match(/^kibana-pr-([0-9]+)$/)[1];
|
||||
const prJson = execSync(`gh pr view '${prNumber}' --json state,labels,commits`).toString();
|
||||
const pullRequest = JSON.parse(prJson);
|
||||
const prOpen = pullRequest.state === 'OPEN';
|
||||
|
||||
const lastCommit = pullRequest.commits.slice(-1)[0];
|
||||
const lastCommitTimestamp = new Date(lastCommit.committedDate).getTime() / 1000;
|
||||
|
||||
if (pullRequest.state !== 'OPEN') {
|
||||
const persistDeployment = Boolean(
|
||||
pullRequest.labels.filter((label: any) => label.name === 'ci:cloud-persist-deployment').length
|
||||
);
|
||||
if (prOpen && persistDeployment) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!prOpen) {
|
||||
console.log(`Pull Request #${prNumber} is no longer open, will delete associated deployment`);
|
||||
deploymentsToPurge.push(deployment);
|
||||
} else if (
|
||||
!pullRequest.labels.filter((label: any) =>
|
||||
/^ci:(deploy-cloud|cloud-deploy|cloud-redeploy)$/.test(label.name)
|
||||
!Boolean(
|
||||
pullRequest.labels.filter((label: any) =>
|
||||
/^ci:(cloud-deploy|cloud-redeploy)$/.test(label.name)
|
||||
).length
|
||||
)
|
||||
) {
|
||||
console.log(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue