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:
|
jobs:
|
||||||
build-and-deploy:
|
build-and-deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: self-hosted
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: '20'
|
|
||||||
cache: 'npm'
|
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: npm run build
|
run: npm run build
|
||||||
|
|
||||||
- name: Setup SSH
|
- name: Deploy
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ~/.ssh
|
cp -r dist/ /home/hyoseung/english/back/dist/
|
||||||
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_key
|
cd /home/hyoseung/english/back
|
||||||
chmod 600 ~/.ssh/deploy_key
|
pm2 restart english-back || pm2 start dist/main.js --name english-back
|
||||||
ssh-keyscan -H ${{ secrets.SERVER_HOST }} >> ~/.ssh/known_hosts
|
pm2 save
|
||||||
|
|
||||||
- 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"
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user