Skip to content

Commit

Permalink
Remove: triggering workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-sumi-k committed Feb 19, 2024
1 parent 61259d9 commit 65703b1
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 64 deletions.
3 changes: 0 additions & 3 deletions admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
"strapi-plugin-tagsinput": "^1.0.1",
"styled-components": "^5.2.1"
},
"devDependencies": {
"request": "^2.88.2"
},
"author": {
"name": "canopas"
},
Expand Down
60 changes: 0 additions & 60 deletions admin/src/api/post/content-types/post/lifecycles.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ const fs = require("fs");
const path = require("path");
const handlebars = require("handlebars");
const convertToHTML = require("./convertData");
const axios = require("axios");
const request = require("request");
const puppeteer = require("puppeteer");

module.exports = {
async beforeCreate(event) {
await modifyContentAndSetErrorMsg(event);
triggerGithubWorkflow(false);
},

async beforeUpdate(event) {
Expand Down Expand Up @@ -60,68 +57,11 @@ module.exports = {
await strapi.plugins["email"].services.email.send(emailData);
}

triggerGithubWorkflow(true);
}
} else {
triggerGithubWorkflow(false);
}
},
};

function triggerGithubWorkflow(publishing) {
const config = {
headers: {
Accept: "application/vnd.github+json",
Authorization: "Bearer " + process.env.GH_PERSONAL_ACCESS_TOKEN,
},
};

axios
.get(
"https://api.github.com/repos/canopas/canopas-website/actions/runs?branch=master",
config
)
.then((res) => {
let devWorkflow = res.data["workflow_runs"].filter(function (workflow) {
return workflow.name == "DeployFrontendDev";
});

axios.post(
"https://api.github.com/repos/canopas/canopas-website/actions/runs/" +
devWorkflow[0].id +
"/rerun",
null,
{
headers: config.headers,
}
);

if (publishing) {
let prodWorkflow = res.data["workflow_runs"].filter(function (
workflow
) {
return workflow.name == "DeployFrontendProd";
});

axios.post(
"https://api.github.com/repos/canopas/canopas-website/actions/runs/" +
prodWorkflow[0].id +
"/rerun",
null,
{
headers: config.headers,
}
);
}

/** submit sitemap on google after 10 mins (After workflow run will complete and generated sitemap ) */
setTimeout(request(sitemapUrl), 10 * 60 * 1000);
})
.catch((err) => {
console.error(err.message);
});
}

async function modifyContentAndSetErrorMsg(event) {
const result = event.params.data;

Expand Down
2 changes: 1 addition & 1 deletion admin/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9926,7 +9926,7 @@ request-oauth@^1.0.1:
qs "^6.9.6"
uuid "^8.3.2"

[email protected], request@^2.88.2:
[email protected]:
version "2.88.2"
resolved "https://registry.yarnpkg.com/request/-/request-2.88.2.tgz#d73c918731cb5a87da047e207234146f664d12b3"
integrity sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==
Expand Down

0 comments on commit 65703b1

Please sign in to comment.