Add start script to package.json and enhance CI workflow for deployment
CI / build (push) Failing after 48s
CI / deploy (push) Has been skipped

- Introduced a new "start" script in package.json to run the built application.
- Updated the CI workflow to include environment variables for deployment.
- Added steps for uploading build artifacts and deploying to a server using sshpass.
- Configured the deployment process to ensure the application runs on the specified port.
This commit is contained in:
eewing
2026-02-17 09:46:40 -06:00
parent 0c69463e74
commit c9453b19ed
2 changed files with 41 additions and 2 deletions
+40 -2
View File
@@ -6,6 +6,10 @@ on:
pull_request: pull_request:
branches: [main] branches: [main]
env:
DEPLOY_HOST: "10.10.1.82"
DEPLOY_PORT: "3010"
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -25,6 +29,40 @@ jobs:
- name: Build - name: Build
run: bun run build run: bun run build
env: env:
PORT: "3010" PORT: ${{ env.DEPLOY_PORT }}
# Build-time env (VITE_* for client; POCKETBASE_URL has fallback in code)
VITE_POCKETBASE_URL: ${{ vars.VITE_POCKETBASE_URL || 'https://pocketbase.ccllc.pro' }} VITE_POCKETBASE_URL: ${{ vars.VITE_POCKETBASE_URL || 'https://pocketbase.ccllc.pro' }}
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: app
path: |
build
package.json
bun.lockb
deploy:
needs: build
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: app
- name: Install sshpass
run: sudo apt-get update -qq && sudo apt-get install -y sshpass
- name: Deploy to server
env:
DEPLOY_HOST: ${{ env.DEPLOY_HOST }}
DEPLOY_PORT: ${{ env.DEPLOY_PORT }}
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
DEPLOY_PASSWORD: ${{ secrets.DEPLOY_PASSWORD }}
run: |
set -e
ssh-keyscan -H $DEPLOY_HOST >> ~/.ssh/known_hosts 2>/dev/null || true
sshpass -p "$DEPLOY_PASSWORD" ssh -o StrictHostKeyChecking=accept-new $DEPLOY_USER@$DEPLOY_HOST "mkdir -p /var/www/hrm"
sshpass -p "$DEPLOY_PASSWORD" scp -o StrictHostKeyChecking=accept-new -r build package.json bun.lockb $DEPLOY_USER@$DEPLOY_HOST:/var/www/hrm/
sshpass -p "$DEPLOY_PASSWORD" ssh -o StrictHostKeyChecking=accept-new $DEPLOY_USER@$DEPLOY_HOST "cd /var/www/hrm && bun install --frozen-lockfile && pkill -f 'node build' || true; PORT=$DEPLOY_PORT nohup node build > /var/log/hrm.log 2>&1 &"
+1
View File
@@ -7,6 +7,7 @@
"dev": "vite dev", "dev": "vite dev",
"build": "vite build", "build": "vite build",
"preview": "vite preview", "preview": "vite preview",
"start": "node build",
"prepare": "svelte-kit sync || echo ''", "prepare": "svelte-kit sync || echo ''",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch" "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"