localhost #47
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
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | |
name: Node.js production CI | |
on: | |
push: | |
branches: [ main ] | |
paths: | |
- "backend/**" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [14.x] | |
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/ | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Running the Test Suit | |
env: | |
REQUEST_GITHUB_URL_API_ENDPOINT: ${{ secrets.REQUEST_GITHUB_URL_API_ENDPOINT }} | |
MIP_GITHUB_REPOSITORY: ${{ secrets.MIP_GITHUB_REPOSITORY_PROD }} | |
MIP_GITHUB_REPOSITORY_OWNER: ${{ secrets.MIP_GITHUB_REPOSITORY_OWNER_PROD }} | |
GIT_ACCESS_API_TOKEN: ${{ secrets.GIT_ACCESS_API_TOKEN }} | |
run: | | |
cp '.env example' .env | |
npm install | |
npm run pre-start | |
npm test | |
working-directory: backend | |
deploy: | |
needs: [build] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Copy file via scp | |
uses: appleboy/scp-action@master | |
env: | |
HOST: ${{ secrets.SSH_HOST }} | |
USERNAME: ${{ secrets.SSH_USER }} | |
PORT: ${{ secrets.SSH_PORT }} | |
PASSWORD: ${{ secrets.SSH_PASS }} | |
with: | |
source: "./backend" | |
target: "/var/warehouse/makerdao-mips" | |
- name: Executing remote command | |
uses: appleboy/ssh-action@master | |
env: | |
REQUEST_GITHUB_URL_API_ENDPOINT: ${{ secrets.REQUEST_GITHUB_URL_API_ENDPOINT }} | |
MIP_GITHUB_REPOSITORY: ${{ secrets.MIP_GITHUB_REPOSITORY_PROD }} | |
MIP_GITHUB_REPOSITORY_OWNER: ${{ secrets.MIP_GITHUB_REPOSITORY_OWNER_PROD }} | |
GIT_ACCESS_API_TOKEN: ${{ secrets.GIT_ACCESS_API_TOKEN }} | |
with: | |
HOST: ${{ secrets.SSH_HOST }} | |
USERNAME: ${{ secrets.SSH_USER }} | |
PORT: ${{ secrets.SSH_PORT }} | |
PASSWORD: ${{ secrets.SSH_PASS }} | |
script: | | |
cd /var/warehouse/makerdao-mips/backend | |
pm2 stop dist/main.js | |
npm install | |
npm run build | |
npm run pre-start | |
npx nestjs-command drop:db | |
npx nestjs-command parse:mips | |
pm2 start dist/main.js --name "api-prod" |