Skip to main content
command

deploy · microsoft — Claude Code command for VitePress GitHub Pages deployment

This command prepares a GitHub Actions workflow to build and publish a VitePress wiki on GitHub Pages. It also checks the site path and npm lock file.

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/commands/deploy.md
Open on GitHub

What deploy does

The command checks for wiki/ and wiki/package.json, then looks for existing GitHub Pages workflows. If .github/workflows/deploy-wiki.yml is already present, it stops. If it finds a different Pages workflow, it asks whether to create another one. Otherwise, it writes a workflow triggered by changes under wiki/** on main, with a manual run option.

The workflow runs npm ci, builds with npm run build, and publishes the artifact through GitHub Actions. The command also checks the base setting in wiki/.vitepress/config.mts and generates wiki/package-lock.json when needed. GitHub Pages must use “GitHub Actions” as its source or deployment will fail; commit the lock file too.

What it helps with

  • create a workflow to publish VitePress on GitHub Pages
  • avoid creating a duplicate Pages workflow
  • set the project-site base path
  • prepare a lock file for npm ci in CI

Example prompts for the agent

  • /deploy — set up deployment of the site in wiki/ to GitHub Pages.
  • /deploy — check for existing Pages workflows before creating one.
  • /deploy — configure the project site's base path and check the npm lock file.

How to install deploy

Manually: put the files in place

.claude/commands/deploy.md

Call it with /deploy. For all projects use ~/.claude/commands/

Questions about deploy

How do I install deploy in Claude Code?

Create the command file at .claude/commands/deploy.md and add the command contents there.

What does the deploy command do?

It creates .github/workflows/deploy-wiki.yml to build and publish a VitePress wiki on GitHub Pages, and checks the site configuration and npm lock file.

What must be enabled for deployment to work?

In the repository's GitHub Pages settings, select “GitHub Actions” as the publishing source. Commit wiki/package-lock.json as well.

Source text

deploy.md · MIT
---
description: Generate a GitHub Actions workflow to deploy the VitePress wiki site to GitHub Pages
---

# Deep Wiki: Deploy to GitHub Pages

Generate a `.github/workflows/deploy-wiki.yml` GitHub Actions workflow that builds and deploys the VitePress wiki to GitHub Pages.

## Step 1: Check Prerequisites

Before generating the workflow:

1. **Verify wiki exists**: Check that `wiki/` directory and `wiki/package.json` exist
   - If not, tell the user: _"Run `/deep-wiki:build` first to scaffold the VitePress site."_
2. **Check for existing deployment workflows**: Search for ANY existing GitHub Pages workflow:
   ```bash
   # Check for exact file
   ls .github/workflows/deploy-wiki.yml 2>/dev/null
   # Check for any pages-related workflow
   grep -rl "deploy-pages\|pages-artifact\|github-pages" .github/workflows/ 2>/dev/null
   ```
   - If `deploy-wiki.yml` exists → **STOP**. Tell the user: _"A deployment workflow already exists at `.github/workflows/deploy-wiki.yml`. No changes needed."_
   - If a DIFFERENT pages workflow exists → **ASK the user**: _"I found an existing GitHub Pages workflow at `{path}`. Should I skip creating a new one, or create `deploy-wiki.yml` alongside it?"_
   - If no pages workflow exists → proceed with generation

## Step 2: Generate Workflow File

Create `.github/workflows/deploy-wiki.yml`:

```yaml
name: Deploy Wiki to GitHub Pages

on:
  push:
    branches: [main]
    paths:
      - 'wiki/**'
  workflow_dispatch:

permissions:
  contents: read
  pages: write
  id-token: write

concurrency:
  group: pages
  cancel-in-progress: false

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Setup Node
        uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: npm
          cache-dependency-path: wiki/package-lock.json

      - name: Setup Pages
        uses: actions/configure-pages@v5

      - name: Install dependencies
        run: npm ci
        working-directory: wiki

      - name: Build with VitePress
        run: npm run build
        working-directory: wiki

      - name: Upload artifact
        uses: actions/upload-pages-artifact@v3
        with:
          path: wiki/.vitepress/dist

  deploy:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    needs: build
    runs-on: ubuntu-latest
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4
```

### Workflow Details

| Setting | Value | Why |
|---------|-------|-----|
| **Trigger** | Push to `main` on `wiki/**` paths | Only rebuilds when wiki content changes |
| **Manual trigger** | `workflow_dispatch` | Allows manual re-deployment |
| **Node version** | 20 | LTS, required for VitePress 1.x |
| **Cache** | npm with `wiki/package-lock.json` | Speeds up subsequent builds |
| **Concurrency** | `pages` group, no cancel | Prevents parallel deploys |
| **Permissions** | `contents: read`, `pages: write`, `id-token: write` | Minimum required for Pages deployment |

## Step 3: Update VitePress Config for GitHub Pages

Check if `wiki/.vitepress/config.mts` needs a `base` path. GitHub Pages serves from:

- **User/org site** (`username.github.io`): `base: '/'` (default, no change needed)
- **Project site** (`username.github.io/repo-name`): `base: '/repo-name/'`

Detect which case applies:

```bash
# Get the repo name
REPO_NAME=$(basename $(git remote get-url origin) .git)
OWNER=$(git remote get-url origin | sed -E 's|.*[:/]([^/]+)/[^/]+\.git|\\1|')
```

If the repo is NOT named `{owner}.github.io`, add the base path to `config.mts`:

```typescript
export default defineConfig({
  base: '/{repo-name}/',
  // ... rest of config
})
```

## Step 4: Generate package-lock.json

If `wiki/package-lock.json` doesn't exist (required for `npm ci` in CI):

```bash
cd wiki && npm install
```

This generates the lock file. Remind the user to commit it.

## Step 5: Commit and Report

After generating the workflow, output:

```
## GitHub Pages Deployment Setup ✅

### Files Created
- `.github/workflows/deploy-wiki.yml` — GitHub Actions workflow

### Files Modified
- `wiki/.vitepress/config.mts` — Added `base: '/{repo-name}/'` (if project site)

### What You Need To Do

> ⚠️ IMPORTANT: GitHub Pages will NOT work until you complete step 2.

1. **Commit the workflow file:**
   ```bash
   git add .github/workflows/deploy-wiki.yml wiki/package-lock.json
   git commit -m "ci: add GitHub Pages deployment for wiki"
   git push
   ```

2. **Enable GitHub Pages (REQUIRED — deployments will fail without this):**
   - Go to your repo on GitHub → **Settings** → **Pages**
   - Under **Build and deployment**, change **Source** to **"GitHub Actions"**
   - Click **Save**
   - Without this step, the workflow runs but the site is NOT published

3. **Your wiki will be live at:**
   - `https://{owner}.github.io/{repo-name}/` (project site)
   - OR `https://{owner}.github.io/` (if repo is named `{owner}.github.io`)

### Triggering Deployments
- **Automatic**: Every push to `main` that changes `wiki/**` files
- **Manual**: Go to Actions → "Deploy Wiki to GitHub Pages" → "Run workflow"
```

## Troubleshooting Guidance

If the user reports issues, suggest checking:

| Issue | Solution |
|-------|----------|
| 404 on deployed site | Verify `base` path in `config.mts` matches repo name |
| Build fails on `npm ci` | Ensure `wiki/package-lock.json` is committed |
| Pages not enabled | Go to Settings → Pages → Source → select "GitHub Actions" |
| Workflow not triggering | Check that changes are in `wiki/**` and pushed to `main` |
| Mermaid diagrams missing | Ensure `mermaid` and `vitepress-plugin-mermaid` are in `package.json` |

$ARGUMENTS

© microsoft · MIT · microsoft/skills

Similar slash commands

All slash commands for DevOps and infrastructure →

deploy by other authors comes first.

From the same set242

The whole set →

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor