diff --git a/.env.js.secret b/.env.js.secret index 24e33a06..7626a941 100644 Binary files a/.env.js.secret and b/.env.js.secret differ diff --git a/.github/workflows/devDeploy.yml b/.github/workflows/devDeploy.yml new file mode 100644 index 00000000..eda4bf62 --- /dev/null +++ b/.github/workflows/devDeploy.yml @@ -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 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4df892f4..7689ecd7 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -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 @@ -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 @@ -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: diff --git a/.github/workflows/prodDeploy.yml b/.github/workflows/prodDeploy.yml new file mode 100644 index 00000000..5c3e165d --- /dev/null +++ b/.github/workflows/prodDeploy.yml @@ -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 diff --git a/.gitsecret/keys/pubring.gpg b/.gitsecret/keys/pubring.gpg index 5a703549..522fbc39 100644 Binary files a/.gitsecret/keys/pubring.gpg and b/.gitsecret/keys/pubring.gpg differ diff --git a/ecosystem.config.js b/ecosystem.config.js index bc41da0a..27d8b488 100644 --- a/ecosystem.config.js +++ b/ecosystem.config.js @@ -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;', + }, + }, }; diff --git a/package.json b/package.json index 48352e6a..e2262a54 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/server/config/firebase-service-account.json.secret b/server/config/firebase-service-account.json.secret index 20d83e56..2dcf6442 100644 Binary files a/server/config/firebase-service-account.json.secret and b/server/config/firebase-service-account.json.secret differ