Skip to content

Commit

Permalink
Merge branch 'main' into autosave-blog-content-in-editor
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-ashish-k authored Feb 2, 2024
2 parents b3751c0 + fcac5e4 commit f25ec09
Show file tree
Hide file tree
Showing 25 changed files with 2,852 additions and 1,680 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,14 @@ jobs:
- name: Deploy
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SSL_PRIVATE_KEY: |
${{ secrets.SSL_PRIVATE_KEY }}
SSL_PUBLIC_KEY: |
${{ secrets.SSL_PUBLIC_KEY }}
run: |
echo "$SSH_PRIVATE_KEY" > ssh_private_key && chmod 600 ssh_private_key
sed -i "s|ADMIN_PANEL_URL|${{ secrets.ADMIN_PANEL_URL }}|g" admin/nginx/conf.d/website-blog.conf
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}} '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}} 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"'
80 changes: 40 additions & 40 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
name: Deploy to dev
# name: Deploy to dev

on:
push:
branches:
- main
# on:
# push:
# branches:
# - main

jobs:
deploy-dev:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Checkout
uses: actions/[email protected]
# jobs:
# deploy-dev:
# runs-on: ubuntu-latest
# permissions:
# id-token: write
# contents: read
# steps:
# - name: Checkout
# uses: actions/[email protected]

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/github-actions-frontend-access
aws-region: ap-south-1
# - name: Configure AWS credentials
# uses: aws-actions/configure-aws-credentials@v1
# with:
# role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/github-actions-frontend-access
# aws-region: ap-south-1

- name: Build frontend and push on ECR
run: |
cd website
echo NEXT_PUBLIC_IFRAMELY_KEY=${{ secrets.IFRAMELY_KEY_DEV }} >> .env
echo NEXT_PUBLIC_RECAPTCHA_SITE_KEY=${{ secrets.RECAPTCHA_SITE_KEY_DEV }} >> .env
echo NEXT_PUBLIC_MIXPANEL_PROJECT_TOKEN=${{ secrets.MIXPANEL_PROJECT_TOKEN_DEV }} >> .env
echo NEXT_PUBLIC_STRAPI_URL=${{ secrets.STRAPI_URL }} >> .env
echo NEXT_PUBLIC_STRAPI_DOMAIN=${{ secrets.STRAPI_DOMAIN }} >> .env
echo NEXT_PUBLIC_WEBSITE_URL=${{ secrets.WEBSITE_URL_DEV }} >> .env
echo NEXT_PUBLIC_API_BASE=${{ secrets.API_BASE_DEV }} >> .env
bash ./../deploy/deploy-ecr-image.sh dev-blog ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.$AWS_REGION.amazonaws.com/canopas-blog
# - name: Build frontend and push on ECR
# run: |
# cd website
# echo NEXT_PUBLIC_IFRAMELY_KEY=${{ secrets.IFRAMELY_KEY_DEV }} >> .env
# echo NEXT_PUBLIC_RECAPTCHA_SITE_KEY=${{ secrets.RECAPTCHA_SITE_KEY_DEV }} >> .env
# echo NEXT_PUBLIC_MIXPANEL_PROJECT_TOKEN=${{ secrets.MIXPANEL_PROJECT_TOKEN_DEV }} >> .env
# echo NEXT_PUBLIC_STRAPI_URL=${{ secrets.STRAPI_URL }} >> .env
# echo NEXT_PUBLIC_STRAPI_DOMAIN=${{ secrets.STRAPI_DOMAIN }} >> .env
# echo NEXT_PUBLIC_WEBSITE_URL=${{ secrets.WEBSITE_URL_DEV }} >> .env
# echo NEXT_PUBLIC_API_BASE=${{ secrets.API_BASE_DEV }} >> .env
# bash ./../deploy/deploy-ecr-image.sh dev-blog ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.$AWS_REGION.amazonaws.com/canopas-blog

- name: Trigger Canopas website Workflow
uses: actions/github-script@v6
with:
github-token: ${{ secrets.WORKFLOW_TOKEN }}
script: |
await github.rest.repos.createDispatchEvent({
owner: 'canopas',
repo: 'canopas-website',
event_type: 'deploy-blog-dev',
});
# - name: Trigger Canopas website Workflow
# uses: actions/github-script@v6
# with:
# github-token: ${{ secrets.WORKFLOW_TOKEN }}
# script: |
# await github.rest.repos.createDispatchEvent({
# owner: 'canopas',
# repo: 'canopas-website',
# event_type: 'deploy-blog-dev',
# });
82 changes: 41 additions & 41 deletions .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
name: Deploy to prod
# name: Deploy to prod

on:
push:
branches:
- main
# on:
# push:
# branches:
# - main

jobs:
deploy-prod:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Checkout
uses: actions/[email protected]
# jobs:
# deploy-prod:
# runs-on: ubuntu-latest
# permissions:
# id-token: write
# contents: read
# steps:
# - name: Checkout
# uses: actions/[email protected]

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/github-actions-frontend-access
aws-region: ap-south-1
# - name: Configure AWS credentials
# uses: aws-actions/configure-aws-credentials@v1
# with:
# role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/github-actions-frontend-access
# aws-region: ap-south-1

- name: Build frontend and push on ECR
run: |
cd website
echo NEXT_PUBLIC_IFRAMELY_KEY=${{ secrets.IFRAMELY_KEY_PROD }} >> .env
echo NEXT_PUBLIC_RECAPTCHA_SITE_KEY=${{ secrets.RECAPTCHA_SITE_KEY_PROD }} >> .env
echo NEXT_PUBLIC_MIXPANEL_PROJECT_TOKEN=${{ secrets.MIXPANEL_PROJECT_TOKEN_PROD }} >> .env
echo NEXT_PUBLIC_STRAPI_URL=${{ secrets.STRAPI_URL }} >> .env
echo NEXT_PUBLIC_STRAPI_DOMAIN=${{ secrets.STRAPI_DOMAIN }} >> .env
echo NEXT_PUBLIC_WEBSITE_URL=${{ secrets.WEBSITE_URL_PROD }} >> .env
echo NEXT_PUBLIC_API_BASE=${{ secrets.API_BASE_PROD }} >> .env
mv config-prod.js config.js
bash ./../deploy/deploy-ecr-image.sh prod-blog ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.$AWS_REGION.amazonaws.com/canopas-blog
# - name: Build frontend and push on ECR
# run: |
# cd website
# echo NEXT_PUBLIC_IFRAMELY_KEY=${{ secrets.IFRAMELY_KEY_PROD }} >> .env
# echo NEXT_PUBLIC_RECAPTCHA_SITE_KEY=${{ secrets.RECAPTCHA_SITE_KEY_PROD }} >> .env
# echo NEXT_PUBLIC_MIXPANEL_PROJECT_TOKEN=${{ secrets.MIXPANEL_PROJECT_TOKEN_PROD }} >> .env
# echo NEXT_PUBLIC_STRAPI_URL=${{ secrets.STRAPI_URL }} >> .env
# echo NEXT_PUBLIC_STRAPI_DOMAIN=${{ secrets.STRAPI_DOMAIN }} >> .env
# echo NEXT_PUBLIC_WEBSITE_URL=${{ secrets.WEBSITE_URL_PROD }} >> .env
# echo NEXT_PUBLIC_API_BASE=${{ secrets.API_BASE_PROD }} >> .env
# mv config-prod.js config.js
# bash ./../deploy/deploy-ecr-image.sh prod-blog ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.$AWS_REGION.amazonaws.com/canopas-blog

- name: Trigger Canopas website Workflow
uses: actions/github-script@v6
with:
github-token: ${{ secrets.WORKFLOW_TOKEN }}
script: |
await github.rest.repos.createDispatchEvent({
owner: 'canopas',
repo: 'canopas-website',
event_type: 'deploy-blog-prod',
});
# - name: Trigger Canopas website Workflow
# uses: actions/github-script@v6
# with:
# github-token: ${{ secrets.WORKFLOW_TOKEN }}
# script: |
# await github.rest.repos.createDispatchEvent({
# owner: 'canopas',
# repo: 'canopas-website',
# event_type: 'deploy-blog-prod',
# });
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ This is our open-source Next.js blog website of [canopas](https://canopas.com).

## Showcase

This repository contains the working code of [our resources](https://articles.canopas.com/resources). You can check out the link to view a live example of this repository.
This repository contains the working code of [our resources](https://canopas.com/resources). You can check out the link to view a live example of this repository.

### Admin panel for handling content

![Admin panel](https://github.com/canopas/canopas-blog/assets/69897605/5a61df91-94bd-4a09-bced-e811450a2873)
![Admin panel](https://github.com/canopas/canopas-blog/assets/115449373/7542ff05-08ca-45ae-a4c6-24785419ae35)


### Blogs website

Expand Down
2 changes: 1 addition & 1 deletion admin/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ DATABASE_SSL=
IFRAMELY_API_KEY=
HR_FROM_MAIL=
SENTRY_DSN=

GH_PERSONAL_ACCESS_TOKEN=
6 changes: 1 addition & 5 deletions admin/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ RUN yarn install --frozen-lockfile

ENV NODE_ENV production

RUN cd src/plugins/blog-editor

RUN yarn install

RUN cd ../../..
RUN cd src/plugins/blog-editor && yarn install && cd ../../..

RUN yarn build

Expand Down
6 changes: 4 additions & 2 deletions admin/config/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ module.exports = ({ env }) => ({
connection: {
host: env("DATABASE_HOST", "127.0.0.1"),
port: env.int("DATABASE_PORT", 5432),
database: env("DATABASE_NAME", "blogs"),
database: env("DATABASE_NAME", "postgres"),
user: env("DATABASE_USERNAME", "postgres"),
password: env("DATABASE_PASSWORD", "postgres"),
ssl: env.bool("DATABASE_SSL", false),
ssl: {
rejectUnauthorized: env.bool("DATABASE_SSL_SELF", false),
},
},
debug: false,
acquireConnectionTimeout: 600000,
Expand Down
2 changes: 1 addition & 1 deletion admin/config/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = ({ env }) => ({
encodeURIComponent(match[0]);
return (
// If you need, set maxwidth and other styles for 'iframely-embed' class - it's yours to customize
'<div class="iframely-embeddddd">' +
'<div class="iframely-embed">' +
'<div class="iframely-responsive">' +
`<iframe src="${iframeUrl}" ` +
'frameborder="0" allow="autoplay; encrypted-media" allowfullscreen>' +
Expand Down
6 changes: 4 additions & 2 deletions admin/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --

sudo mkdir -p /etc/nginx/conf.d && sudo mv nginx.conf /etc/nginx/ && sudo mv conf.d/website-blog.conf /etc/nginx/conf.d/

sudo mkdir -p /etc/nginx/certs && echo -e $SSL_PRIVATE_KEY > /etc/nginx/certs/blog.live.domain.name.key && echo -e $SSL_PUBLIC_KEY > /etc/nginx/certs/blog.live.domain.name.cert
sudo mkdir -p /etc/nginx/certs && sudo mv certs/blog.live.domain.name.key /etc/nginx/certs/blog.live.domain.name.key && sudo mv certs/blog.live.domain.name.cert /etc/nginx/certs/blog.live.domain.name.cert

docker stack deploy --with-registry-auth -c ./docker-compose.yaml canopas-website
docker stack deploy --with-registry-auth -c ./docker-compose.yaml canopas-website

docker system prune --force
14 changes: 1 addition & 13 deletions admin/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ services:
image: ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/blog-admin:${GITHUB_SHA}-${GITHUB_RUN_ATTEMPT}-blog-admin
deploy:
replicas: 1
depends_on:
- db
volumes:
- uploads:/srv/app/public/uploads
ports:
Expand All @@ -29,17 +27,7 @@ services:
AWS_BUCKET_URL: ${AWS_BUCKET_URL}
SENTRY_DSN: ${SENTRY_DSN}
HR_FROM_MAIL: ${HR_FROM_MAIL}

db:
image: postgres:15.1-alpine
environment:
POSTGRES_USER: ${DATABASE_USERNAME}
POSTGRES_PASSWORD: ${DATABASE_PASSWORD}
POSTGRES_DB: ${DATABASE_NAME}
volumes:
- blog-data:/var/lib/postgresql/data/
ports:
- "5432:5432"
GH_PERSONAL_ACCESS_TOKEN: ${GH_PERSONAL_ACCESS_TOKEN}

nginx:
image: nginx:latest
Expand Down
Empty file.
Empty file.
8 changes: 8 additions & 0 deletions admin/nginx/conf.d/website-blog.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ server {
listen 80;
listen [::]:80;
server_name ADMIN_PANEL_URL;
return 301 https://ADMIN_PANEL_URL$request_uri;
}

server {
listen 443 ssl http2;
server_name ADMIN_PANEL_URL;
ssl_certificate certs/blog.live.domain.name.cert;
ssl_certificate_key certs/blog.live.domain.name.key;

location = /basic_status {
stub_status;
Expand Down
15 changes: 11 additions & 4 deletions admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "website-blog",
"private": true,
"version": "0.1.0",
"description": "A headless starpi CMS for blogs website",
"description": "A headless strapi CMS for blogs website",
"scripts": {
"develop": "strapi develop",
"start": "strapi start",
Expand All @@ -16,14 +16,21 @@
"@strapi/plugin-users-permissions": "^4.11.5",
"@strapi/provider-email-amazon-ses": "^4.11.5",
"@strapi/provider-upload-aws-s3": "^4.11.5",
"@strapi/strapi": "^4.11.5",
"@strapi/strapi": "^4.14.3",
"@webbio/strapi-plugin-scheduler": "^1.0.6",
"html-loader": "^5.0.0",
"jsdom": "^22.1.0",
"markdown-loader": "^8.0.0",
"pg": "^8.11.1",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-router-dom": "^5.2.0",
"react-tagsinput": "^3.20.3",
"reading-time": "^1.5.0",
"strapi-plugin-tagsinput": "^1.0.1"
"strapi-plugin-tagsinput": "^1.0.1",
"styled-components": "^5.2.1"
},
"devDependencies": {
"request": "^2.88.2"
},
"author": {
"name": "canopas"
Expand Down
2 changes: 1 addition & 1 deletion admin/public/emailTemplates/comment.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ <h1 style="font-size: x-large">Canopas blogs</h1>
<h2 style="margin-top: 0">{{postTitle}}</h2>
<p style="margin-bottom: 27px">{{summary}}</p>
<a
href="https://canopas.com/resources/{{slug}}"
href="https://canopas.com/{{slug}}"
style="
background-color: #3d3d3d;
color: #fff;
Expand Down
4 changes: 2 additions & 2 deletions admin/public/emailTemplates/subscribe.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ <h1 style="font-size: x-large">
Recently posted in Canopas blogs
</h1>
<a
href="https://canopas.com/resources/{{slug}}"
href="https://canopas.com/{{slug}}"
style="color: #000000; text-decoration: none"
>
{{#if imageUrl}}
Expand All @@ -79,7 +79,7 @@ <h1 style="font-size: x-large">{{postTitle}}</h1>
marketing emails.if you'd prefer to not recieve these
emails,please
<a
href="https://canopas.com/resources/unsubscribe?email={{userEmail}}"
href="https://canopas.com/unsubscribe?email={{userEmail}}"
>unsubscribe</a
>.
</p>
Expand Down
2 changes: 1 addition & 1 deletion admin/src/api/author/content-types/author/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"bio": {
"type": "text",
"required": true,
"maxLength": 250,
"maxLength": 500,
"minLength": 30
}
}
Expand Down
4 changes: 3 additions & 1 deletion admin/src/api/cta/content-types/cta/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
"type": "media",
"multiple": false,
"required": false,
"allowedTypes": ["images"]
"allowedTypes": [
"images"
]
},
"posts": {
"type": "relation",
Expand Down
Loading

0 comments on commit f25ec09

Please sign in to comment.