From d1afc3b3af85e2c05e4f567a402a2746b5eb4df8 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 22 Apr 2022 23:02:48 +0300 Subject: [PATCH 1/3] test commit --- src/develop_actions.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/develop_actions.js b/src/develop_actions.js index 721f153..7edc15d 100644 --- a/src/develop_actions.js +++ b/src/develop_actions.js @@ -40,7 +40,6 @@ const run = async () => { base: "staging", } ); - console.log("createPr", createpr?.data); if (createpr?.data) { axios .post( From ca8226e300cac9484a524c96a90ae3dec1b4c4f8 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 22 Apr 2022 23:07:44 +0300 Subject: [PATCH 2/3] test sending random slack notification --- src/develop_actions.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/develop_actions.js b/src/develop_actions.js index 7edc15d..ec48ee0 100644 --- a/src/develop_actions.js +++ b/src/develop_actions.js @@ -43,16 +43,16 @@ const run = async () => { if (createpr?.data) { axios .post( - `${SLACK_WEBHOOK_URL}`, - `PR from ${branch_name} to staging was created successfully` + SLACK_WEBHOOK_URL, + JSON.stringify( + `PR from ${branch_name} to staging was created successfully` + ) ) .then((response) => { console.log("SUCCEEDED: Sent slack webhook", response.data); - resolve(response.data); }) .catch((error) => { console.log("FAILED: Send slack webhook", error); - reject(new Error("FAILED: Send slack webhook")); }); } const compare_commits = await octokit.request( From 9fc989367c945595d45f1b71098f5b862f730242 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 22 Apr 2022 23:12:13 +0300 Subject: [PATCH 3/3] test sending random slack notification --- src/develop_actions.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/develop_actions.js b/src/develop_actions.js index ec48ee0..fa76d8d 100644 --- a/src/develop_actions.js +++ b/src/develop_actions.js @@ -40,6 +40,7 @@ const run = async () => { base: "staging", } ); + console.log(createpr?.data); if (createpr?.data) { axios .post( @@ -54,6 +55,21 @@ const run = async () => { .catch((error) => { console.log("FAILED: Send slack webhook", error); }); + } else { + // fetch pr from branch_name to staging + // update existing pr + console.log("pr exists"); + axios + .post( + SLACK_WEBHOOK_URL, + JSON.stringify(`PR from ${branch_name} to staging already exist`) + ) + .then((response) => { + console.log("SUCCEEDED: Sent slack webhook", response.data); + }) + .catch((error) => { + console.log("FAILED: Send slack webhook", error); + }); } const compare_commits = await octokit.request( `GET /repos/${context.payload?.repository?.full_name}/compare/staging...${branch_name}`,