Skip to content

Commit 2998fec

Browse files
committed
chore : temporarily disabling auto ephemeral environment creation
1 parent 3f5cc3a commit 2998fec

2 files changed

Lines changed: 30 additions & 5 deletions

File tree

controllers/gitlab.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const { gitlab } = require('../config');
2-
const { gitlabPushRequest, gitlabCommentOnCommit, gitlabMergeRequest } = require('../services/gitlab');
2+
const { gitlabPushRequest, gitlabCommentOnCommit, gitlabMergeRequest, gitlabMergeRequestOnCloseAndMerge } = require('../services/gitlab');
33
const { log } = require('@spaship/common/lib/logging/pino');
44

55
module.exports.post = async (req, res) => {
@@ -9,9 +9,7 @@ module.exports.post = async (req, res) => {
99

1010
if (action === gitlab.PUSH_REQUEST && payload?.event_name === gitlab.STATE_PUSHED) await gitlabPushRequest(payload);
1111
else if (action === gitlab.COMMENT_REQUEST) await gitlabCommentOnCommit(payload);
12-
else if (action === gitlab.MERGE_REQUEST && payload?.object_attributes?.state === gitlab.STATE_OPENED) await gitlabMergeRequest(payload);
13-
/* @internal To be used during the ephemeral env support for containerized deployments
12+
else if (action === gitlab.MERGE_REQUEST && payload?.object_attributes?.state === gitlab.STATE_OPENED) await gitlabMergeRequest(payload);
1413
else if (payload?.object_attributes?.state === gitlab.STATE_MERGED || payload?.object_attributes?.state === gitlab.STATE_CLOSED) await gitlabMergeRequestOnCloseAndMerge(payload);
15-
*/
1614
res.sendStatus(200);
1715
};

services/gitlab/index.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ const gitlabMergeRequest = async (payload) => {
2626
return;
2727
}
2828
const envs = envList.filter((env) => env.cluster == 'preprod').map((property) => property.env);
29+
const commentBody = `📗 Kindly specify the names of environment you want to deploy [Registered Environment : ${envs.toString()}].`;
30+
log.info(commentBody);
31+
try {
32+
await commentOnGitlabMergeRequest(payload, projectId, mergeRequestId, commentBody);
33+
} catch (error) {
34+
log.error(error);
35+
}
36+
/*
37+
@internal Temporarily disabling Auto Ephemeral Environment Creation
2938
if (envs.length) {
3039
try {
3140
const contextDir = '/';
@@ -43,6 +52,7 @@ const gitlabMergeRequest = async (payload) => {
4352
await commentOnGitlabMergeRequest(payload, projectId, mergeRequestId, error.message);
4453
}
4554
}
55+
*/
4656
};
4757

4858
const gitlabPushRequest = async (payload) => {
@@ -73,10 +83,22 @@ const gitlabPushRequest = async (payload) => {
7383

7484
const gitlabCommentOnCommit = async (payload) => {
7585
if (!payload?.object_attributes?.description?.startsWith(deployment.SPECIFIER)) return;
76-
const commitId = payload.commit.id;
86+
const commitId = payload?.commit?.id;
87+
if (!commitId) {
88+
log.info("No commit ID found in payload. Skipping gitlabCommentOnCommit.");
89+
return;
90+
}
7791
const projectId = payload.project.id;
7892
const repoUrl = payload?.repository?.homepage;
7993
const commentBody = payload.object_attributes.description;
94+
log.info(
95+
`Gitlab Comment rquest: {
96+
id: ${commitId},
97+
projectId: ${projectId},
98+
repoUrl: ${repoUrl},
99+
commentBody: ${commentBody}
100+
}`
101+
);
80102
let envList;
81103
try {
82104
await commentOnGitlabCommit(payload, projectId, commitId, "⌛️ We're Currently Processing the Deployment Request, Please wait for sometime.");
@@ -153,6 +175,11 @@ const gitlabMergeRequestOnCloseAndMerge = async (payload) => {
153175
if (!deploymentEnvs?.size) return;
154176
const envs = Array.from(deploymentEnvs);
155177
const contextDir = payload.object_attributes.source.change_path || '/';
178+
try {
179+
await commentOnGitlabMergeRequest(payload, projectId, mergeRequestId, "⌛️ We're Currently Processing the Deployment Request, Please wait for sometime.");
180+
} catch (error) {
181+
log.error(error);
182+
}
156183
try {
157184
const orchestratorPayload = createOrchestratorPayload(payload, contextDir, envs, '', '');
158185
const response = await orchestratorDeploymentRequest(orchestratorPayload);

0 commit comments

Comments
 (0)