deploy · microsoft — команда для Claude Code: деплой VitePress на GitHub Pages
Команда создаёт GitHub Actions workflow для сборки и публикации сайта VitePress на GitHub Pages. Она также проверяет настройки base и наличие lock-файла.
.claude/commands/deploy.mdЧто делает deploy
Команда проверяет, что в проекте есть wiki/ и wiki/package.json, а затем ищет существующие workflow для GitHub Pages. Если deploy-wiki.yml уже есть, она остановится; при другом workflow спросит, создавать ли новый. После проверки создаёт .github/workflows/deploy-wiki.yml с ручным запуском и запуском при изменениях в wiki/** на ветке main.
Workflow устанавливает зависимости через npm ci, собирает сайт командой npm run build и публикует артефакт через GitHub Actions. Команда также проверяет base в wiki/.vitepress/config.mts и создаёт wiki/package-lock.json, если его нет. Без включённого GitHub Pages с источником «GitHub Actions» деплой завершится ошибкой; lock-файл нужно добавить в коммит.
Какие задачи решает
- создать workflow для публикации VitePress на GitHub Pages
- не запускать повторное создание уже существующего workflow
- настроить
baseдля сайта проекта в GitHub Pages - подготовить
package-lock.jsonдляnpm ciв CI
Примеры запросов агенту
/deploy— подготовь деплой сайта изwiki/на GitHub Pages./deploy— проверь существующие workflow и создай новый, если конфликта нет./deploy— настройbaseдля репозитория проекта и проверь lock-файл.
Как установить deploy
Вручную: положить файлы
.claude/commands/deploy.mdВызов — /deploy. Для всех проектов — ~/.claude/commands/
Вручную: положить файлы
~/.codex/prompts/deploy.mdВызов — /prompts:deploy. В Codex этот формат помечен устаревшим, замена — скиллы
Вручную: положить файлы
.github/prompts/deploy.prompt.mdВручную: положить файлы
.gemini/commands/deploy.tomlGemini хранит команды в TOML: текст запроса — в поле prompt
Вопросы о deploy
Как установить deploy в Claude Code?
Создайте файл команды по пути .claude/commands/deploy.md и поместите туда содержимое команды.
Что делает команда deploy?
Она готовит .github/workflows/deploy-wiki.yml для сборки и публикации VitePress на GitHub Pages, а также проверяет конфигурацию сайта и lock-файл.
Что нужно включить, чтобы публикация заработала?
В настройках репозитория GitHub откройте Pages и выберите «GitHub Actions» как источник сборки. Также wiki/package-lock.json должен быть закоммичен.
Исходный текст
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
Похожие слэш-команды
Все слэш-команды по теме «DevOps и инфраструктура» →Сначала — deploy от других авторов.