Merge pull request #27 from purwadhikafullstack/develop #9
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 | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.x] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Generate web .env file | |
run: echo '${{ secrets.ENV_WEB }}' >> ./apps/web/.env | |
- name: Generate api .env file | |
run: echo '${{ secrets.ENV_API }}' >> ./apps/api/.env | |
- name: Build Project | |
run: | | |
npm install | |
npx prisma generate --schema=./apps/api/prisma/schema.prisma | |
npm run build | |
- name: Deploy to Linode | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USERNAME }} | |
password: ${{ secrets.SSH_PASSWORD }} | |
port: ${{ secrets.SSH_PORT }} | |
source: './apps/web/.next, ./apps/web/*, ./apps/web/.*, ./apps/api, ./deploy.config.js, ./package*.json, ./turbo.json, ./.husky' | |
target: '${{ secrets.SSH_FOLDER }}' | |
- name: Run App | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USERNAME }} | |
password: ${{ secrets.SSH_PASSWORD }} | |
port: ${{ secrets.SSH_PORT }} | |
script: | | |
export NVM_DIR=~/.nvm | |
source ~/.nvm/nvm.sh | |
cd ${{ secrets.SSH_FOLDER }} | |
npm install | |
npx prisma generate --schema=./apps/api/prisma/schema.prisma | |
pm2 start deploy.config.js |