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 7aef19f
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 68 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ jobs:
echo -e "$SSL_PRIVATE_KEY" > admin/nginx/certs/blog.live.domain.name.key && echo -e "$SSL_PUBLIC_KEY" > admin/nginx/certs/blog.live.domain.name.cert
scp -o StrictHostKeyChecking=no -i ssh_private_key -r admin/nginx ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_ADDRESS }}:blog-admin-deployment
cat admin/deploy.sh | ssh -o StrictHostKeyChecking=no -i ssh_private_key ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_ADDRESS }} 'cat > ./blog-admin-deployment/deploy.sh'
cat admin/docker-compose.yaml | ssh -o StrictHostKeyChecking=no -i ssh_private_key ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_ADDRESS }} sudo PUBLISH_PORT=${{secrets.PUBLISH_PORT}} APP_KEYS=${{secrets.APP_KEYS}} API_TOKEN_SALT=${{secrets.API_TOKEN_SALT}} ADMIN_JWT_SECRET=${{secrets.ADMIN_JWT_SECRET}} JWT_SECRET=${{secrets.JWT_SECRET}} DATABASE_CLIENT=${{secrets.DATABASE_CLIENT}} DATABASE_HOST=${{secrets.DATABASE_HOST}} DATABASE_PORT=${{secrets.DATABASE_PORT}} DATABASE_NAME=${{secrets.DATABASE_NAME}} DATABASE_USERNAME=${{secrets.DATABASE_USERNAME}} DATABASE_PASSWORD=${{secrets.DATABASE_PASSWORD}} DATABASE_SSL=${{secrets.DATABASE_SSL}} AWS_ACCOUNT_ID=${{secrets.AWS_ACCOUNT_ID}} AWS_ACCESS_KEY_ID=${{secrets.AWS_ACCESS_KEY_ID}} AWS_SECRET_ACCESS_KEY=${{secrets.AWS_SECRET_ACCESS_KEY}} AWS_REGION=${{secrets.AWS_REGION}} AWS_BUCKET=${{secrets.AWS_BUCKET}} AWS_BUCKET_URL=${{secrets.AWS_BUCKET_URL}} GITHUB_SHA=${{github.sha}} GITHUB_RUN_ATTEMPT=${{github.run_attempt}} SENTRY_DSN=${{secrets.SENTRY_DSN}} HR_FROM_MAIL=${{secrets.HR_FROM_MAIL}} GH_PERSONAL_ACCESS_TOKEN=${{secrets.GH_PERSONAL_ACCESS_TOKEN}} 'bash -c "cd blog-admin-deployment && cat > docker-compose.yaml && chmod -R 755 ./deploy.sh && ./deploy.sh && cd .. && rm -rf blog-admin-deployment"'
cat admin/docker-compose.yaml | ssh -o StrictHostKeyChecking=no -i ssh_private_key ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_ADDRESS }} sudo PUBLISH_PORT=${{secrets.PUBLISH_PORT}} APP_KEYS=${{secrets.APP_KEYS}} API_TOKEN_SALT=${{secrets.API_TOKEN_SALT}} ADMIN_JWT_SECRET=${{secrets.ADMIN_JWT_SECRET}} JWT_SECRET=${{secrets.JWT_SECRET}} DATABASE_CLIENT=${{secrets.DATABASE_CLIENT}} DATABASE_HOST=${{secrets.DATABASE_HOST}} DATABASE_PORT=${{secrets.DATABASE_PORT}} DATABASE_NAME=${{secrets.DATABASE_NAME}} DATABASE_USERNAME=${{secrets.DATABASE_USERNAME}} DATABASE_PASSWORD=${{secrets.DATABASE_PASSWORD}} DATABASE_SSL=${{secrets.DATABASE_SSL}} AWS_ACCOUNT_ID=${{secrets.AWS_ACCOUNT_ID}} AWS_ACCESS_KEY_ID=${{secrets.AWS_ACCESS_KEY_ID}} AWS_SECRET_ACCESS_KEY=${{secrets.AWS_SECRET_ACCESS_KEY}} AWS_REGION=${{secrets.AWS_REGION}} AWS_BUCKET=${{secrets.AWS_BUCKET}} AWS_BUCKET_URL=${{secrets.AWS_BUCKET_URL}} GITHUB_SHA=${{github.sha}} GITHUB_RUN_ATTEMPT=${{github.run_attempt}} SENTRY_DSN=${{secrets.SENTRY_DSN}} HR_FROM_MAIL=${{secrets.HR_FROM_MAIL}} 'bash -c "cd blog-admin-deployment && cat > docker-compose.yaml && chmod -R 755 ./deploy.sh && ./deploy.sh && cd .. && rm -rf blog-admin-deployment"'
3 changes: 1 addition & 2 deletions admin/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ DATABASE_USERNAME=
DATABASE_PASSWORD=
DATABASE_SSL=
HR_FROM_MAIL=
SENTRY_DSN=
GH_PERSONAL_ACCESS_TOKEN=
SENTRY_DSN=
1 change: 0 additions & 1 deletion admin/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ services:
AWS_BUCKET_URL: ${AWS_BUCKET_URL}
SENTRY_DSN: ${SENTRY_DSN}
HR_FROM_MAIL: ${HR_FROM_MAIL}
GH_PERSONAL_ACCESS_TOKEN: ${GH_PERSONAL_ACCESS_TOKEN}

nginx:
image: nginx:latest
Expand Down
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 7aef19f

Please sign in to comment.