Update node.js.yml #1
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: Node.js Production | |
on: | |
push: | |
branches: [main] | |
jobs: | |
build: | |
runs-on: [self-hosted, main] | |
env: | |
NODE_ENV: production | |
DOTENV_KEY: ${{ secrets.DOTENV_KEY }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: szenius/[email protected] | |
with: | |
timezoneLinux: "Africa/Nairobi" | |
- name: Set dotenv variable | |
run: | | |
export NODE_ENV=production | |
export DOTENV_KEY="${{ secrets.DOTENV_KEY }}" | |
export NODE_TLS_REJECT_UNAUTHORIZED=0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '18' | |
- name: Install PM2 | |
run: npm install -g pm2 | |
- name: Start PM2 | |
run: pm2 status || pm2 resurrect | |
- name: Install Node.js dependencies | |
run: npm install | |
- name: Start application | |
run: pm2 describe tictactoe-production &> /dev/null && pm2 reload ecosystem.config.js --env production --update-env || pm2 start ecosystem.config.js --env production |