Skip to content

Docker configuration #20

Docker configuration

Docker configuration #20

name: Main-Branch-CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
Main-Branch-Pre-Integration-Tests:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v3
# Installing Node.js at the test instance
- name: Setting up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
# Printing the node version in the terminal
- name: Checking Node Version
run: node --version
# Installation of Node packaging Manager (npm)
- name: Installing Node packaging Manager (npm)
run: npm ci
# Setting up the environment variable from using credentials stored in GitHub actions secret
- name: Setting up environment variables
run: |
echo "MY_ENV_VARIABLE=${{ secrets.ENV_FILE }}" >> .env
# Installation of Node packaging Manager (npm)
- name: Installing project dependencies
run: npm install
# Checking if node modules were installed (Done by simply checking if the node_modules directory exists or not)
- name: Checking if node_modules directory was created after installing NPM
run: |
if [ ! -d "node_modules" ]; then
echo "Error: node_modules directory does not exist."
exit 1
fi
# Installation of Process Manager 2 (PM2)
- name: Installing Process Manager 2 (PM2)
run: npm i pm2 -g
# Start the application with Process Manager 2 (PM2)
- name: Initiating the application with Process Manager 2 (PM2)
run: pm2 start ./bin/www --name "production-server"
# Log the status of application with Process Manager 2 (PM2)
- name: Logging the status of application with Process Manager 2 (PM2)
run: pm2 status all