ci: add Gitea Actions build and deploy workflow
Some checks are pending
Build and Deploy / build-and-deploy (push) Waiting to run

This commit is contained in:
hyoseung 2026-05-12 13:35:20 +09:00
parent ad897dc1e1
commit baf5f74808

View File

@ -0,0 +1,50 @@
name: Build and Deploy
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Setup SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
ssh-keyscan -H ${{ secrets.SERVER_HOST }} >> ~/.ssh/known_hosts
- name: Deploy dist to server
run: |
rsync -avz --delete \
-e "ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no" \
dist/ \
${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }}:/home/hyoseung/english/back/dist/
rsync -avz \
-e "ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no" \
package.json package-lock.json \
${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }}:/home/hyoseung/english/back/
- name: Install production deps & restart PM2
run: |
ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no \
${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} \
"cd /home/hyoseung/english/back && npm ci --omit=dev && pm2 restart english-back || pm2 start dist/main.js --name english-back && pm2 save"