ci: use self-hosted runner for direct deployment
Some checks failed
Build and Deploy / build-and-deploy (push) Failing after 13m34s
Some checks failed
Build and Deploy / build-and-deploy (push) Failing after 13m34s
This commit is contained in:
parent
2549334adb
commit
f881377ae0
@ -7,44 +7,21 @@ on:
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: self-hosted
|
||||
|
||||
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
|
||||
- name: Deploy
|
||||
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"
|
||||
cp -r dist/ /home/hyoseung/english/back/dist/
|
||||
cd /home/hyoseung/english/back
|
||||
pm2 restart english-back || pm2 start dist/main.js --name english-back
|
||||
pm2 save
|
||||
|
||||
Loading…
Reference in New Issue
Block a user