All checks were successful
Build and Deploy to Web Server / deploy (push) Successful in 16m0s
59 lines
1.5 KiB
YAML
59 lines
1.5 KiB
YAML
name: Build and Deploy to Web Server
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
lfs: true
|
|
|
|
- name: Setup Node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
cache: npm
|
|
cache-dependency-path: "./package-lock.json"
|
|
|
|
- name: Install
|
|
shell: "bash"
|
|
working-directory: .
|
|
run: npm install
|
|
|
|
- name: Build
|
|
shell: "bash"
|
|
working-directory: .
|
|
run: npm run build
|
|
|
|
- name: Set up SSH
|
|
run: |
|
|
mkdir -p ~/.ssh
|
|
echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/id_rsa
|
|
chmod 600 ~/.ssh/id_rsa
|
|
ssh-keyscan -H "${{ secrets.DEPLOY_HOST }}" >> ~/.ssh/known_hosts
|
|
|
|
- name: Install rsync
|
|
run: |
|
|
apt-get update
|
|
apt-get install -y rsync
|
|
|
|
- name: Deploy via rsync
|
|
run: |
|
|
rsync -avz --delete --exclude 'node_modules/' ./dist/ ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }}:${{ secrets.DEPLOY_DIRECTORY }}
|
|
|
|
- name: Copy package.json via rsync
|
|
run: |
|
|
rsync -avz ./package*.json ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }}:${{ secrets.DEPLOY_DIRECTORY }}
|
|
|
|
- name: Install and restart service
|
|
run: |
|
|
ssh ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }} '/home/deployers/${{ secrets.DEPLOY_USER }}/deploy.sh'
|