chore: update nixpacks #69
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: 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 build api | |
npx copyfiles -f apps/**/*.graphql libs/**/*.graphql dist/apps/api/graphql | |
- name: Zip artifacts | |
run: | | |
tar -czvf build.tar.gz dist/apps/api prisma/ | |
- 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/flare/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/flare | |
tar -xzvf build.tar.gz | |
npm run prod | |
pm2 stop flare | |
pm2 start dist/apps/api/main.js --name flare | |
rm -rf build.tar.gz |