Skip to content

fix :: deploy.yml

fix :: deploy.yml #55

Workflow file for this run

name: Deploy dear-web
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Install dependencies
run: yarn install
- name: Create config directory and config.json
run: |
mkdir -p ./src/config
echo '${{ secrets.CONFIG }}' > ./src/config/config.json
- name: Build Next.js project
run: yarn run build
- name: Deploy to EC2
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ec2-user
key: ${{ secrets.PRIVATE_KEY }}
port: ${{ secrets.PORT }}
source: ".next/*"
target: "/var/www/dear"
- name: Reload PM2 for zero-downtime deployment
run: |
ssh -o StrictHostKeyChecking=no ec2-user@${{ secrets.HOST }} "
cd /var/www/dear &&
pm2 start yarn --name dear -- start &&
pm2 reload dear
"