Merge pull request #22 from Bloceducare/development #83
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CD Workflow | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: self-hosted | |
env: | |
MONGO_URL: ${{ secrets.MONGO_URL }} | |
CLOUDINARY_API_KEY: ${{ secrets.CLOUDINARY_API_KEY }} | |
CLOUDINARY_API_SECRET: ${{ secrets.CLOUDINARY_API_SECRET }} | |
SENDGRID_API_KEY: ${{ secrets.SENDGRID_API_KEY }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "16.x" | |
- name: Install dependencies | |
run: npm install | |
- name: Write env file | |
run: | | |
echo "MONGO_URL=${MONGO_URL}" >> .env | |
echo "CLOUDINARY_API_KEY=${CLOUDINARY_API_KEY}" >> .env | |
echo "CLOUDINARY_API_SECRET=${CLOUDINARY_API_SECRET}" >> .env | |
echo "SENDGRID_API_KEY=${SENDGRID_API_KEY}" >> .env | |
- name: Build app | |
run: npm run build | |
- name: Copy Server File | |
run: cp -r .next /var/www/web3-lagos | |
- name: Restart Server | |
run: pm2 restart web3-lagos || pm2 start --name web3-lagos npm -- start | |
# - name: Clean up Installations | |
# run: rm -vrf node_modules | |
# deploy: | |
# needs: build | |
# runs-on: self-hosted | |
# env: | |
# NODE_ENV: production | |
# PORT: 3004 | |
# MONGODB_URI: ${{ secrets.MONGODB_URI }} |