fix :: deploy.yml 변경 #66
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 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 build | |
- name: Make zip file | |
run: zip -qq -r ./chagok.zip . -x "node_modules/*" | |
- name: Deploy zip to EC2 | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ec2-user | |
key: ${{ secrets.PRIVATE_KEY }} | |
port: ${{ secrets.PORT }} | |
source: "./chagok.zip" | |
target: "/home/ec2-user/www/dear" | |
- name: SSH into EC2 and unzip, install dependencies, start with PM2 | |
env: | |
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }} | |
run: | | |
echo "${PRIVATE_KEY}" > private_key.pem | |
chmod 600 private_key.pem | |
ssh -i private_key.pem -o StrictHostKeyChecking=no ec2-user@${{ secrets.HOST }} " | |
cd /home/ec2-user/www/dear && | |
unzip -o ./chagok.zip && | |
yarn install --production && | |
pm2 restart dear || pm2 start yarn --name dear -- start | |
" |