Skip to content

chore: revert api endpoint change #94

chore: revert api endpoint change

chore: revert api endpoint change #94

Workflow file for this run

name: Deploy API
on:
push:
branches: [main]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: 'just-a-placeholder'
- name: Adding Known Hosts
run: ssh-keyscan -H ${{ secrets.REMOTE_SERVER_ADDRESS }} >> ~/.ssh/known_hosts
- uses: actions/checkout@v2
- name: Build API
run: |
npm install
npm run after:install
npm run build api --configuration=production
- name: Create Sentry release
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
with:
environment: PRODUCTION
sourcemaps: './dist/app/api'
- name: Zip artifacts
run: |
tar -czvf build.tar.gz dist/ prisma/ package*
- name: Send artifacts to remote
env:
REMOTE_SERVER_USER: ${{ secrets.REMOTE_SERVER_USER }}
REMOTE_SERVER_ADDRESS: ${{ secrets.REMOTE_SERVER_ADDRESS }}
run: |
rsync -azIv ./build.tar.gz $REMOTE_SERVER_USER@$REMOTE_SERVER_ADDRESS:/home/$REMOTE_SERVER_USER/compito/build.tar.gz
- name: Start API
uses: appleboy/ssh-action@master
env:
REMOTE_SERVER_USER: ${{ secrets.REMOTE_SERVER_USER }}
with:
host: ${{ secrets.REMOTE_SERVER_ADDRESS }}
username: ${{ secrets.REMOTE_SERVER_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
envs: REMOTE_SERVER_USER
script: |
cd /home/$REMOTE_SERVER_USER/compito
tar -xzvf build.tar.gz
npm install
npx prisma migrate deploy
npx prisma generate
pm2 stop compito
pm2 start dist/apps/api/main.js --name compito
rm -rf build.tar.gz