Files
mcpedia/.github/workflows/ci.yml
T
asepharyana 586a2f341f fix: CI — include-hidden-files:true for .next upload (hidden dir bug)
ROOT CAUSE: 'apps/web/.next/' starts with a dot — it's a HIDDEN directory.
actions/upload-artifact@v4 excludes hidden files by default
(include-hidden-files: false). This is why the artifact was always empty,
causing 'Artifact not found' in the deploy job.

Fix: set include-hidden-files: true and use path without glob.
Also fix deploy job download path to apps/web and SCP source to match.
2026-08-21 12:24:18 +07:00

108 lines
3.2 KiB
YAML

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: typecheck + build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Set up Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: "1.3.14"
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Typecheck
run: bun run typecheck
- name: Build web
working-directory: apps/web
run: bun run build
# Upload the built .next directory (hidden dir, so include-hidden-files).
# The deploy job downloads this and copies to the VPS — no build on VPS.
- name: Upload web build artifact
uses: actions/upload-artifact@v4
with:
name: mcpedia-web-build
path: apps/web/.next
include-hidden-files: true
if-no-files-found: error
# Smoke: verify the MCP server + resources load and the indexer/module
# graph resolves. Requires Postgres + Redis — only runs when available.
- name: MCP smoke test
if: env.DATABASE_URL != ''
working-directory: apps/mcp
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
REDIS_URL: ${{ secrets.REDIS_URL }}
run: bun run smoke
# Unit tests across all packages + apps. CI has no Postgres/Redis, so
# tests use bun:test module mocking to stub @mcpedia/db, @mcpedia/queue,
# and @mcpedia/embeddings — no live I/O.
- name: Test
run: bun run test
deploy:
name: deploy to VPS
needs: build
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: mcpedia-web-build
path: apps/web
- name: Copy pre-built .next to VPS
uses: appleboy/scp-action@v1
with:
host: ${{ secrets.SSH_DEPLOY_HOST }}
port: ${{ secrets.SSH_DEPLOY_PORT }}
username: ${{ secrets.SSH_DEPLOY_USER }}
key: ${{ secrets.SSH_DEPLOY_KEY }}
source: "apps/web/.next/*"
target: "/home/code/mcpedia/apps/web/.next"
- name: Deploy to VPS over SSH
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.SSH_DEPLOY_HOST }}
port: ${{ secrets.SSH_DEPLOY_PORT }}
username: ${{ secrets.SSH_DEPLOY_USER }}
key: ${{ secrets.SSH_DEPLOY_KEY }}
envs: SSH_DEPLOY_HOST
script: |
set -e
cd /home/code/mcpedia
# Pull latest code (content, .env, non-web changes)
git pull origin main
/home/code/.bun/bin/bun install --frozen-lockfile
/home/code/.bun/bin/bun run scripts/indexer.ts
# .next/ was just copied from CI (pre-built, no build on VPS)
sudo systemctl restart mcpedia-web mcpedia-api mcpedia-mcp mcpedia-worker
sleep 3
systemctl --no-pager status mcpedia-web mcpedia-api mcpedia-mcp mcpedia-worker --no-legend