Skip to content

Commit b2a09b4

Browse files
authored
Merge pull request #8 from hideokamoto/claude/create-docs-landing-page-01GSymTUuksUYZHApLxCMp5b
Add documentation landing page for Cloudflare Workers deployment
2 parents 922a383 + 0bf3e49 commit b2a09b4

16 files changed

Lines changed: 6693 additions & 3 deletions

File tree

.github/workflows/deploy-docs.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Deploy Documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
release:
8+
types: [published]
9+
workflow_dispatch: # 手動トリガーも可能に
10+
11+
jobs:
12+
deploy:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
deployments: write
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: '20'
26+
cache: 'npm'
27+
cache-dependency-path: docs/package-lock.json
28+
29+
- name: Install dependencies
30+
run: |
31+
cd docs
32+
npm ci
33+
34+
- name: Build site
35+
run: |
36+
cd docs
37+
npm run build
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
41+
- name: Deploy to Cloudflare Workers
42+
run: |
43+
cd docs
44+
npx wrangler deploy
45+
env:
46+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
47+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}

.npmignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Documentation site (deployed separately to Cloudflare Workers)
2+
docs/
3+
4+
# Development
5+
*.log
6+
.DS_Store
7+
8+
# Git
9+
.git/
10+
.github/
11+
.gitignore

docs/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
dist/
3+
.astro/

docs/DEPLOYMENT.md

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
# Deployment Guide
2+
3+
このドキュメントサイトは、Cloudflare Workers Static Assetsを使用して自動デプロイされます。
4+
5+
## 自動デプロイ(推奨)
6+
7+
GitHub Actionsを使用した自動デプロイが設定されています。
8+
9+
### トリガー条件
10+
11+
以下のタイミングで自動的にビルド&デプロイが実行されます:
12+
13+
- `main`ブランチへのプッシュ
14+
- 新しいリリースの公開
15+
- 手動トリガー(GitHub Actionsページから)
16+
17+
### 初回セットアップ
18+
19+
1. **Cloudflare API トークンを取得**
20+
- Cloudflare Profile > API Tokens
21+
- Create Token > "Edit Cloudflare Workers" テンプレートを選択
22+
- Account Resources: 該当アカウントを選択
23+
- Zone Resources: All zones (または特定のゾーン)
24+
- トークンをコピー
25+
26+
2. **GitHubシークレットを設定**
27+
28+
リポジトリの Settings > Secrets and variables > Actions で以下を追加:
29+
30+
- `CLOUDFLARE_API_TOKEN`: 上記で作成したAPIトークン
31+
- `CLOUDFLARE_ACCOUNT_ID`: CloudflareのAccount ID
32+
- ダッシュボードのURLから取得: `dash.cloudflare.com/[Account ID]`
33+
34+
3. **設定ファイルの確認**
35+
36+
`docs/wrangler.toml` の内容を確認:
37+
```toml
38+
name = "create-mcp-tools-docs" # 任意の名前に変更可能
39+
compatibility_date = "2024-01-01"
40+
41+
[assets]
42+
directory = "dist"
43+
not_found_handling = "404-page"
44+
```
45+
46+
4. **完了!**
47+
48+
これで、`main`ブランチへのプッシュや新しいリリースの公開時に、自動的にドキュメントサイトが更新されます。
49+
50+
## 手動デプロイ
51+
52+
### 方法1: GitHub Actionsから手動実行
53+
54+
1. GitHubリポジトリの Actions タブを開く
55+
2. "Deploy Documentation" ワークフローを選択
56+
3. "Run workflow" ボタンをクリック
57+
58+
### 方法2: ローカルからWranglerでデプロイ
59+
60+
```bash
61+
cd docs
62+
npm install
63+
npm run build
64+
npx wrangler deploy
65+
```
66+
67+
初回は認証が必要です:
68+
```bash
69+
npx wrangler login
70+
```
71+
72+
## Cloudflare Workers Static Assetsについて
73+
74+
このプロジェクトは、Cloudflare Workers の Static Assets 機能を使用しています。
75+
76+
### 特徴
77+
78+
- **高速**: Cloudflareのグローバルネットワークでコンテンツを配信
79+
- **スケーラブル**: 自動的にスケール、トラフィック制限なし
80+
- **シンプル**: Workerスクリプト不要で静的ファイルを直接配信
81+
- **無料**: 静的アセットへのリクエストは無料
82+
83+
### 仕組み
84+
85+
1. Astroで静的サイトをビルド → `dist/` ディレクトリに出力
86+
2. Wranglerが `dist/` 内のファイルをCloudflareにアップロード
87+
3. Cloudflareが静的アセットを自動的に配信(Workerスクリプト不要)
88+
89+
## データの更新
90+
91+
GitHubのリリースノートとREADMEは、ビルド時に自動的に取得されます。
92+
93+
- **リリース情報**: GitHub APIから最新5件を取得
94+
- **README**: リポジトリルートの `README.md` を読み込み
95+
96+
ビルドスクリプト: `docs/scripts/fetch-github-data.js`
97+
98+
### GitHub APIレート制限について
99+
100+
デフォルトでは未認証でGitHub APIにアクセスするため、1時間あたり60リクエストの制限があります。
101+
102+
**推奨**: GitHub Personal Access Tokenを設定してレート制限を回避(1時間あたり5,000リクエスト)
103+
104+
1. [GitHub Settings > Developer settings > Personal access tokens](https://github.com/settings/tokens) でトークンを作成
105+
2. スコープ: `public_repo` (または読み取り専用でOK)
106+
3. 環境変数に設定:
107+
- ローカル開発: `.env` ファイルに `GITHUB_TOKEN=your_token_here`
108+
- GitHub Actions: すでに `secrets.GITHUB_TOKEN` が自動的に利用可能
109+
- 本番ビルド: Cloudflare Workersの環境変数に設定(オプション)
110+
111+
## カスタムドメインの設定
112+
113+
### Workers.devサブドメイン
114+
115+
デプロイ後、自動的に `https://create-mcp-tools-docs.<your-subdomain>.workers.dev` でアクセス可能。
116+
117+
### カスタムドメイン
118+
119+
1. Cloudflareでドメインを管理
120+
2. `wrangler.toml` に routes を追加:
121+
```toml
122+
routes = [
123+
{ pattern = "docs.example.com", custom_domain = true }
124+
]
125+
```
126+
3. 再デプロイ: `npx wrangler deploy`
127+
128+
または、Cloudflare Dashboardから設定:
129+
1. Workers & Pages > create-mcp-tools-docs
130+
2. Settings > Triggers > Custom Domains
131+
3. "Add Custom Domain" でドメインを追加
132+
133+
## ローカル開発
134+
135+
### 開発サーバー
136+
137+
```bash
138+
cd docs
139+
npm run dev
140+
```
141+
142+
ブラウザで `http://localhost:4321` を開く
143+
144+
### Wranglerでローカルプレビュー
145+
146+
```bash
147+
cd docs
148+
npm run build
149+
npx wrangler dev
150+
```
151+
152+
実際のWorkers環境と同じようにローカルでテスト可能。
153+
154+
## トラブルシューティング
155+
156+
### ビルドが失敗する
157+
158+
- Node.jsのバージョンを確認(20以上を推奨)
159+
- `docs/package-lock.json` が最新か確認
160+
- GitHub Actionsのログを確認
161+
162+
### GitHubデータが取得できない
163+
164+
- GitHub APIのレート制限に達していないか確認
165+
- リポジトリが公開されているか確認
166+
- `scripts/fetch-github-data.js` のリポジトリ名を確認
167+
168+
### デプロイはされるがサイトが表示されない
169+
170+
- `wrangler.toml` の設定を確認
171+
- ビルド出力ディレクトリが `dist` になっているか確認
172+
- Worker名が一意か確認
173+
- Cloudflare Dashboardでデプロイログを確認
174+
175+
### Wranglerのデプロイエラー
176+
177+
```
178+
Error: A request to the Cloudflare API failed.
179+
```
180+
181+
- `CLOUDFLARE_API_TOKEN` が正しく設定されているか確認
182+
- トークンに必要な権限があるか確認
183+
- `CLOUDFLARE_ACCOUNT_ID` が正しいか確認
184+
185+
## コスト
186+
187+
Cloudflare Workersの無料プランでは:
188+
- 100,000 リクエスト/日
189+
- 静的アセットのストレージは無制限
190+
191+
通常のドキュメントサイトであれば、無料プラン内で運用可能です。
192+
193+
## 参考リンク
194+
195+
- [Cloudflare Workers Static Assets](https://developers.cloudflare.com/workers/static-assets/)
196+
- [Wrangler CLI](https://developers.cloudflare.com/workers/wrangler/)
197+
- [Astro Documentation](https://docs.astro.build/)

docs/README.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# create-mcp-tools Documentation Site
2+
3+
このディレクトリには、create-mcp-toolsの静的ドキュメントサイトが含まれています。
4+
5+
Astroで構築され、GitHubのリリースノートとREADMEを動的に取得して表示します。
6+
7+
## 開発
8+
9+
### セットアップ
10+
11+
```bash
12+
cd docs
13+
npm install
14+
```
15+
16+
### 開発サーバーの起動
17+
18+
```bash
19+
npm run dev
20+
```
21+
22+
ブラウザで `http://localhost:4321` を開くとサイトをプレビューできます。
23+
24+
### ビルド
25+
26+
```bash
27+
npm run build
28+
```
29+
30+
このコマンドは以下を実行します:
31+
1. GitHubからリリースノートとREADMEを取得 (`scripts/fetch-github-data.js`)
32+
2. Astroで静的サイトをビルド
33+
3. `dist/` ディレクトリに出力
34+
35+
## デプロイ方法
36+
37+
### Cloudflare Workers Static Assetsへのデプロイ
38+
39+
1. Wranglerをインストール:
40+
```bash
41+
npm install -g wrangler
42+
```
43+
44+
2. Cloudflareにログイン:
45+
```bash
46+
wrangler login
47+
```
48+
49+
3. ビルドしてデプロイ:
50+
```bash
51+
npm run build
52+
npx wrangler deploy
53+
```
54+
55+
詳細は `DEPLOYMENT.md` を参照してください。
56+
57+
## ファイル構成
58+
59+
```
60+
docs/
61+
├── src/
62+
│ ├── pages/ # ページファイル
63+
│ │ ├── index.astro # 英語版トップページ
64+
│ │ └── ja/
65+
│ │ └── index.astro # 日本語版トップページ
66+
│ ├── layouts/ # レイアウトコンポーネント
67+
│ ├── components/ # 再利用可能なコンポーネント
68+
│ └── data/ # GitHubから取得したデータ
69+
├── scripts/
70+
│ └── fetch-github-data.js # GitHubデータ取得スクリプト
71+
├── astro.config.mjs # Astro設定
72+
├── wrangler.toml # Cloudflare Workers設定
73+
└── package.json
74+
75+
```
76+
77+
## 多言語対応
78+
79+
- 英語: `/` (デフォルト)
80+
- 日本語: `/ja`
81+
82+
## 技術スタック
83+
84+
- **Astro**: 静的サイトジェネレーター
85+
- **Cloudflare Workers**: Static Assets機能を使用
86+
- **GitHub Actions**: 自動ビルド&デプロイ
87+
88+
## 注意事項
89+
90+
このディレクトリはnpmパッケージには含まれません。親ディレクトリの`.npmignore`で除外されています。
91+
92+
## デプロイURL
93+
94+
デプロイ後、以下のURLでアクセス可能:
95+
- `https://create-mcp-tools-docs.<your-subdomain>.workers.dev`
96+
97+
カスタムドメインの設定方法は `DEPLOYMENT.md` を参照。

docs/astro.config.mjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { defineConfig } from 'astro/config';
2+
3+
export default defineConfig({
4+
output: 'static',
5+
outDir: './dist',
6+
site: process.env.SITE_URL || 'https://create-mcp-tools-docs.workers.dev',
7+
i18n: {
8+
defaultLocale: 'en',
9+
locales: ['en', 'ja'],
10+
routing: {
11+
prefixDefaultLocale: false
12+
}
13+
}
14+
});

0 commit comments

Comments
 (0)