Update deploy.yml #26
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 backend | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone repo | |
uses: actions/checkout@v4 | |
- name: Create .env file | |
run: | | |
touch .env | |
echo PORT=${{secrets.PORT}} >> .env | |
echo DATABASE_URL="${{secrets.DATABASE_URL}}" >> .env | |
echo PRISMA_SCHEMA=src/db/schema.prisma >> .env | |
cat .env | |
- name: Install bun | |
uses: oven-sh/setup-bun@v1 | |
- name: Install repo dependencies | |
run: bun install | |
- name: Run prisma migrations | |
run: bun prisma migrate deploy | |
- name: Compile backend | |
run: bun run build | |
- name: Upload compiled code | |
uses: SamKirkland/[email protected] | |
with: | |
server: ${{ secrets.FTP_SERVER }} | |
username: ${{ secrets.FTP_USERNAME }} | |
password: ${{ secrets.FTP_PASSWORD }} | |
protocol: ftps | |
exclude: | | |
**/.git/* | |
**/.git*/** | |
**/node_modules/** | |
src/** | |
.env.example | |
bun.lockb | |
LICENSE.txt | |
package.json | |
README.md | |
server.ts | |
setup | |
setup.ps1 | |
tsconfig.json | |
tsoa.json | |
- name: Connect to the server and start production | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USERNAME }} | |
password: ${{ secrets.SSH_PASSWORD }} | |
script: | | |
pwd | |
cd /var/www/html/backend/ | |
pm2 stop all | |
pm2 start --interpreter build/server.js |