Skip to content

Commit

Permalink
Enable CI/CD for Project Reclamation (#49)
Browse files Browse the repository at this point in the history
* Update npm scripts

* Update git secrets

Add mm@server1.dashnet.in

* Update pm2 ecosystem with deploy settings

* Update npm scripts from pm2-runtime to pm2

* Update ecosystem post-deploy command

* Update post-deploy script in pm2 ecosystem

Bug fix git secret clean to remove

* Update github workflows

Change list to be triggered on approval of PR; Create devDeploy and prodDeploy scripts for CI/CD
  • Loading branch information
rutajdash authored Jan 25, 2021
1 parent b600740 commit f8190c7
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 10 deletions.
Binary file modified .env.js.secret
Binary file not shown.
26 changes: 26 additions & 0 deletions .github/workflows/devDeploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Development Server Deploy

on:
push:
branches: [development]
paths:
- '.env.js.secret'
- 'ecosystem.config.js'
- 'package.json'
- 'server/**'

jobs:
devDeploy:
name: Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: '14'

- name: Run PM2 Deploy
run: npx pm2 deploy staging
7 changes: 6 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
name: Lint Check

on: [pull_request]
on:
pull_request_review:
types: [submitted]

jobs:
eslint:
name: ESLint Check
runs-on: ubuntu-latest
if: github.event.review.state == 'approved'
steps:
- name: Checkout Repository
uses: actions/checkout@v1
Expand All @@ -19,6 +22,7 @@ jobs:
prettier:
name: Prettier Check
runs-on: ubuntu-latest
if: github.event.review.state == 'approved'
steps:
- name: Checkout Repository
uses: actions/checkout@v2
Expand All @@ -38,6 +42,7 @@ jobs:
- name: comment PR
uses: unsplash/comment-on-pr@master
if: contains(${{ steps.prettier_run.outputs.prettier_output }}, '.');
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/prodDeploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Production Server Deploy

on:
release:
types: [released]

jobs:
devDeploy:
name: Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: '14'

- name: Run PM2 Deploy
run: npx pm2 deploy production
Binary file modified .gitsecret/keys/pubring.gpg
Binary file not shown.
20 changes: 20 additions & 0 deletions ecosystem.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,24 @@ module.exports = {
...ENV_VARS,
},
],
deploy: {
staging: {
user: 'mm',
host: 'server1.dashnet.in',
ref: 'origin/development',
repo: 'git@github.com:Monday-Morning/project-reclamation.git',
path: '~/www',
'post-deploy':
'rm -f -r node_modules; git secret remove; npm install; git secret reveal; npm run start:stage; npx pm2 dump;',
},
production: {
user: 'github',
host: 'mm.nitrkl.ac.in',
ref: 'origin/production',
repo: 'git@github.com:Monday-Morning/project-reclamation.git',
path: '/var/www',
'post-deploy':
'rm -f -r node_modules; git secret remove; npm install --only=production; git secret reveal; npm run start:prod; npx pm2 dump;',
},
},
};
19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
"description": "The Server Application for Monday Morning under Project Infinity",
"main": "app.js",
"scripts": {
"start": "npx pm2 start ecosystem.config.js --env development",
"start:stage": "pm2-runtime start ecosystem.config.js --env staging",
"start:prod": "pm2-runtime start ecosystem.config.js --env production",
"stop": "npx pm2 kill",
"stop:stage": "pm2-runtime stop all && pm2-runtime kill",
"stop:prod": "pm2-runtime stop all && pm2-runtime kill",
"restart": "npx pm2 restart all",
"restart:stage": "pm2-runtime restart all",
"restart:prod": "pm2-runtime restart all",
"start": "npx pm2 startOrGracefulReload ecosystem.config.js --env development",
"start:stage": "pm2 startOrGracefulReload ecosystem.config.js --env staging",
"start:prod": "pm2 startOrGracefulReload ecosystem.config.js --env production",
"stop": "npx pm2 stop ecosystem.config.js && npx pm2 delete ecosystem.config.js",
"stop:stage": "pm2 stop ecosystem.config.js && pm2 delete ecosystem.config.js",
"stop:prod": "pm2 stop ecosystem.config.js && pm2 delete ecosystem.config.js",
"restart": "npx pm2 restart ecosystem.config.js",
"restart:stage": "pm2 restart ecosystem.config.js",
"restart:prod": "pm2 restart ecosystem.config.js",
"pm2:list": "pm2 list",
"test": "SET NODE_ENV=test && npx mocha --package ./package.json --check-leaks --reporter spec --exit",
"docs:html": "npx jsdoc -c ./.jsdoc.conf.js --readme ./README.md --package ./package.json -r ./server",
"docs:md": "npx jsdoc2md -c ./.jsdoc.conf.js -f ./app.js > ./docs/APP.md && npx jsdoc2md -c ./.jsdoc.conf.js -f ./server/config/*.js > ./docs/CONFIG.md && npx jsdoc2md -c ./.jsdoc.conf.js -f ./server/controllers/*.js > ./docs/CONTROLLERS.md && npx jsdoc2md -c ./.jsdoc.conf.js -f ./server/gql/**/*.js > ./docs/GQL.md && npx jsdoc2md -c ./.jsdoc.conf.js -f ./server/mdb/**/*.js > ./docs/MDB.md && npx jsdoc2md -c ./.jsdoc.conf.js -f ./server/routes/*.js > ./docs/ROUTES.md"
Expand Down
Binary file modified server/config/firebase-service-account.json.secret
Binary file not shown.

0 comments on commit f8190c7

Please sign in to comment.