From b390552cf18b89f4a00861446527691a8f956183 Mon Sep 17 00:00:00 2001 From: marketing-shibata50 Date: Sun, 20 Jul 2025 12:43:31 +0900 Subject: [PATCH 01/18] feat: complete guide navigation and cross-links MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add comprehensive navigation links between all guides - Include learning flow diagrams with visual progression - Update index.md with links to completed guides - Add Pull Request complete guide with advanced features - Add GitHub Projects V2 complete guide with Agile implementation - Implement consistent cross-navigation structure across all pages 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- features/01-repository-basics.md | 23 +- features/02-issues-management.md | 23 + features/03-pull-requests.md | 934 +++++++++++++++++++++++++++++++ features/04-github-projects.md | 756 +++++++++++++++++++++++++ index.md | 8 +- 5 files changed, 1739 insertions(+), 5 deletions(-) create mode 100644 features/03-pull-requests.md create mode 100644 features/04-github-projects.md diff --git a/features/01-repository-basics.md b/features/01-repository-basics.md index 1236135..5701b53 100644 --- a/features/01-repository-basics.md +++ b/features/01-repository-basics.md @@ -410,4 +410,25 @@ GitHub リポジトリの基本機能をマスターすることで: ✅ **リリース管理** - タグとリリース機能による体系的なバージョン管理 ✅ **セキュリティ** - 適切な設定による安全なコード管理 -次は[Issue管理編](02-issues-management.md)で、プロジェクト管理の基礎を学習しましょう。 \ No newline at end of file +## 🔗 関連ガイド + +- **次のステップ**: [Issues管理編](02-issues-management.md) - プロジェクト管理の基礎 +- **さらに学習**: [Pull Request編](03-pull-requests.md) - コードレビューフロー +- **プロジェクト管理**: [GitHub Projects編](04-github-projects.md) - アジャイル開発手法 +- **総合ガイド**: [GitHub完全活用ガイド](../GITHUB_COMPLETE_GUIDE.md) - 全機能の詳細解説 + +## 📖 学習フロー + +```mermaid +graph LR + A[リポジトリ基礎] --> B[Issues管理] + B --> C[Pull Request] + C --> D[GitHub Projects] + D --> E[完全活用] + + style A fill:#e1f5fe + style B fill:#f3e5f5 + style C fill:#e8f5e8 + style D fill:#fff3e0 + style E fill:#fce4ec +``` \ No newline at end of file diff --git a/features/02-issues-management.md b/features/02-issues-management.md index 82e434c..160628a 100644 --- a/features/02-issues-management.md +++ b/features/02-issues-management.md @@ -590,4 +590,27 @@ GitHub Issues を効果的に活用することで: ✅ **コスト削減** - 有料ツールからの移行によるコスト最適化 ✅ **チーム協調** - 透明性の高い情報共有とコミュニケーション +## 🔗 関連ガイド + +- **前のステップ**: [リポジトリ基礎編](01-repository-basics.md) - GitHub の基本操作 +- **次のステップ**: [Pull Request編](03-pull-requests.md) - コードレビューとマージプロセス +- **さらに学習**: [GitHub Projects編](04-github-projects.md) - アジャイル開発プロジェクト管理 +- **総合ガイド**: [GitHub完全活用ガイド](../GITHUB_COMPLETE_GUIDE.md) - 全機能の詳細解説 + +## 📖 学習フロー + +```mermaid +graph LR + A[リポジトリ基礎] --> B[Issues管理] + B --> C[Pull Request] + C --> D[GitHub Projects] + D --> E[完全活用] + + style A fill:#f3e5f5 + style B fill:#e1f5fe + style C fill:#e8f5e8 + style D fill:#fff3e0 + style E fill:#fce4ec +``` + 次は[Pull Request編](03-pull-requests.md)で、コードレビューとマージプロセスを学習しましょう。 \ No newline at end of file diff --git a/features/03-pull-requests.md b/features/03-pull-requests.md new file mode 100644 index 0000000..3f0a36c --- /dev/null +++ b/features/03-pull-requests.md @@ -0,0 +1,934 @@ +--- +layout: default +title: "Pull Request完全ガイド" +description: "効率的なコードレビューフローとPull Request最適化の完全解説" +--- + +# 🔄 Pull Request - 効率的なコードレビューフロー + +GitHubのPull Request機能を最大限活用して、高品質なコード開発とチーム協調を実現する完全ガイド。外部ツールに依存せず、GitHub標準機能のみで企業レベルのコードレビュープロセスを構築します。 + +## 🎯 学習目標 + +- Pull Requestワークフローの完全理解と最適化 +- 効率的なコードレビュープロセスの構築 +- Draft PR、Suggested Changes等の高度機能活用 +- 自動化による品質向上とレビュー効率化 +- 外部ツール(GitLab MR、Bitbucket PR等)との比較理解 + +## 📚 目次 + +1. [Pull Request基本ワークフロー](#1-pull-request基本ワークフロー) +2. [効果的なPR作成方法](#2-効果的なpr作成方法) +3. [コードレビューのベストプラクティス](#3-コードレビューのベストプラクティス) +4. [高度なPR機能活用](#4-高度なpr機能活用) +5. [自動化とCI/CD連携](#5-自動化とcicd連携) +6. [外部ツールとの比較](#6-外部ツールとの比較) + +--- + +## 1. Pull Request基本ワークフロー + +### 🌊 GitHub Flowによる開発プロセス + +#### 理想的なPRライフサイクル +```mermaid +graph LR + A[Issue作成] --> B[ブランチ作成] + B --> C[コード実装] + C --> D[Draft PR作成] + D --> E[CI/CD実行] + E --> F[レビュー依頼] + F --> G[コードレビュー] + G --> H[修正対応] + H --> I[承認] + I --> J[マージ] + J --> K[ブランチ削除] + K --> L[デプロイ] +``` + +#### 基本的なPR作成手順 + +**1. 機能ブランチの作成** +```bash +# メインブランチから最新を取得 +git checkout main +git pull origin main + +# 機能ブランチを作成 +git checkout -b feature/user-authentication + +# または GitHub CLI で +gh repo fork --clone +git checkout -b feature/user-authentication +``` + +**2. 実装とコミット** +```bash +# 変更を実装 +# ... コーディング ... + +# ステージングとコミット +git add . +git commit -m "feat(auth): implement user login functionality + +- Add login form component +- Implement JWT authentication +- Add password validation +- Update user state management + +Closes #123" + +# リモートにプッシュ +git push origin feature/user-authentication +``` + +**3. Pull Request作成** +```bash +# GitHub CLI でPR作成 +gh pr create \ + --title "feat: User authentication system" \ + --body-file .github/pull_request_template.md \ + --assignee @me \ + --reviewer team-lead,senior-dev \ + --label "enhancement,frontend" + +# または Web UI で作成 +# https://github.com/username/repo/compare/main...feature/user-authentication +``` + +### 📋 効果的なPRタイトルとコミットメッセージ + +#### Conventional Commits準拠の形式 +```bash +# タイプ別の例 +feat(auth): add two-factor authentication support +fix(api): resolve timeout issue in user endpoint +docs(readme): update installation instructions +style(css): improve responsive design for mobile +refactor(utils): simplify date formatting functions +test(auth): add comprehensive login flow tests +chore(deps): update dependencies to latest versions +ci(actions): optimize build performance +``` + +#### 詳細なコミットメッセージテンプレート +``` +(): + + + +Breaking Changes: +- List any breaking changes + +Closes: #123, #456 +Related: #789 +``` + +--- + +## 2. 効果的なPR作成方法 + +### 📝 PRテンプレートの活用 + +#### 包括的なPRテンプレート +```markdown +## 📋 変更内容の要約 + + +## 🎯 関連Issue・タスク +Fixes #(issue番号) +Closes #(issue番号) +Related to #(issue番号) + +## 🔄 変更の種類 +- [ ] 🐛 バグ修正 +- [ ] ✨ 新機能 +- [ ] 💥 破壊的変更 +- [ ] 📚 ドキュメント更新 +- [ ] 🎨 スタイル改善(機能に影響なし) +- [ ] ♻️ リファクタリング +- [ ] ⚡ パフォーマンス改善 +- [ ] ✅ テスト追加・修正 +- [ ] 🔧 設定・ビルドシステム変更 + +## 🧪 テスト方法 + + +### 手動テスト手順 +1. +2. +3. + +### 自動テスト +- [ ] 単体テスト追加・更新 +- [ ] 統合テスト追加・更新 +- [ ] E2Eテスト追加・更新 +- [ ] 既存テストがすべて通ることを確認 + +## 📸 スクリーンショット・デモ + + +| Before | After | +|--------|-------| +| | | + +## 🔍 レビュー観点 + + +### 重点確認項目 +- [ ] 機能要件を満たしているか +- [ ] エラーハンドリングが適切か +- [ ] パフォーマンスへの影響はないか +- [ ] セキュリティ面で問題ないか + +## ✅ 作成者チェックリスト +- [ ] コードが自己文書化されている +- [ ] 適切なコメントが追加されている +- [ ] ドキュメントが更新されている +- [ ] テストカバレッジが十分 +- [ ] 破壊的変更がある場合、CHANGELOGに記載 +- [ ] セキュリティの観点で問題がない +- [ ] モバイル・レスポンシブ対応確認済み + +## 📝 その他・備考 + +``` + +### 🎨 Draft PRの効果的活用 + +#### Draft PRの使用場面 +```bash +# 作業進行中のフィードバック取得 +gh pr create --draft \ + --title "WIP: User authentication system" \ + --body "作業中のコードです。アプローチについてフィードバックをお願いします" + +# 設計相談・アーキテクチャレビュー用 +gh pr create --draft \ + --title "RFC: New API architecture proposal" \ + --body "新しいAPI設計について議論したく、Draft PRを作成しました" + +# CI/CDテスト用 +gh pr create --draft \ + --title "Test: CI pipeline validation" \ + --body "新しいワークフローのテスト用Draft PR" +``` + +#### Draft → Ready フロー +```bash +# レビュー準備完了時 +gh pr ready + +# またはWeb UIで「Ready for review」ボタンをクリック +``` + +--- + +## 3. コードレビューのベストプラクティス + +### 👥 効果的なレビュープロセス + +#### レビュアーの責務 +```markdown +### 🔍 確認観点チェックリスト + +#### 機能性・要件 +- [ ] 要件仕様を満たしているか +- [ ] ユーザーストーリーの受け入れ条件をクリアしているか +- [ ] エッジケースが考慮されているか +- [ ] エラーハンドリングが適切か + +#### コード品質 +- [ ] 可読性:命名規則、コメント、構造 +- [ ] 保守性:モジュール化、再利用性 +- [ ] DRY原則:重複コードの排除 +- [ ] SOLID原則:設計原則の遵守 + +#### パフォーマンス +- [ ] 不要な処理・ループがないか +- [ ] メモリ使用量は適切か +- [ ] データベースクエリは最適化されているか +- [ ] キャッシュ戦略は適切か + +#### セキュリティ +- [ ] 入力値検証が適切か +- [ ] 認証・認可が正しく実装されているか +- [ ] 機密情報の漏洩リスクはないか +- [ ] SQLインジェクション等の脆弱性対策 + +#### テスト +- [ ] テストカバレッジは十分か +- [ ] テストケースは適切か +- [ ] モックの使用は適切か +- [ ] エッジケースのテストがあるか +``` + +#### 建設的なレビューコメント例 +```markdown +# ❌ 避けるべきコメント +これはダメです。 + +# ✅ 建設的なコメント +この実装だと、将来的にスケールした際にパフォーマンス問題が発生する可能性があります。 +以下のような改善案はいかがでしょうか? + +```suggestion +// パフォーマンス改善案 +const memoizedResult = useMemo(() => { + return expensiveCalculation(data); +}, [data]); +``` + +### 🎯 Suggested Changes機能の活用 + +#### 具体的な修正提案 +```markdown +# レビューコメントで具体的な修正案を提示 + +```suggestion +// 修正前 +const user = users.find(u => u.id === userId); +if (user) { + return user.name; +} +return null; + +// 修正後:Optional chainingとNullish coalescingを使用 +return users.find(u => u.id === userId)?.name ?? null; +``` + +この修正により、コードがより簡潔で読みやすくなります。 +``` + +#### 複数行の修正提案 +```markdown +```suggestion +const validateUser = (userData) => { + // バリデーションロジックの改善 + const errors = {}; + + if (!userData.email || !isValidEmail(userData.email)) { + errors.email = 'Valid email is required'; + } + + if (!userData.password || userData.password.length < 8) { + errors.password = 'Password must be at least 8 characters'; + } + + return { + isValid: Object.keys(errors).length === 0, + errors + }; +}; +``` +``` + +### 📊 レビュー効率化 + +#### レビュー自動化設定 +```yaml +# .github/CODEOWNERS +# レビュー担当者の自動アサイン + +# デフォルト +* @team-lead @senior-developer + +# フロントエンド +/src/components/ @frontend-team @ui-specialist +/src/styles/ @frontend-team + +# バックエンド +/api/ @backend-team @architecture-lead +/database/ @backend-team @database-specialist + +# セキュリティ関連 +/auth/ @security-team @team-lead +/encryption/ @security-team + +# インフラ・DevOps +/.github/ @devops-team +/docker/ @devops-team +/kubernetes/ @devops-team + +# ドキュメント +/docs/ @tech-writer @team-lead +README.md @tech-writer +``` + +--- + +## 4. 高度なPR機能活用 + +### 🔄 マージ戦略の選択 + +#### マージオプションの使い分け +```bash +# 1. Merge commit(履歴を保持) +gh pr merge --merge + +# 2. Squash and merge(履歴を整理) +gh pr merge --squash + +# 3. Rebase and merge(リニア履歴) +gh pr merge --rebase +``` + +#### 推奨マージ戦略 +```markdown +### プロジェクト規模別の推奨方法 + +#### 小〜中規模プロジェクト +- **Squash and merge** を推奨 +- 機能単位でのクリーンな履歴 +- 簡潔なcommit message + +#### 大規模プロジェクト +- **Merge commit** を推奨 +- 詳細な作業履歴の保持 +- リバート時の容易性 + +#### オープンソース +- **Rebase and merge** を推奨 +- リニアで美しい履歴 +- Bisectの効率性 +``` + +### 🔒 ブランチ保護ルール + +#### 推奨保護設定 +```markdown +### main ブランチ保護ルール + +#### 基本設定 +- ✅ Require a pull request before merging +- ✅ Require approvals: 2人以上(チーム規模に応じて調整) +- ✅ Dismiss stale PR approvals when new commits are pushed +- ✅ Require review from code owners + +#### ステータスチェック +- ✅ Require status checks to pass before merging +- ✅ Require branches to be up to date before merging +- 必須チェック項目: + - continuous-integration/github-actions + - security/code-scanning + - testing/unit-tests + - testing/e2e-tests + +#### 高度な設定 +- ✅ Require conversation resolution before merging +- ✅ Require linear history(必要に応じて) +- ✅ Include administrators(管理者も同様のルールに従う) +- ❌ Allow force pushes +- ❌ Allow deletions +``` + +### 🚀 プルリクエスト自動化 + +#### 自動ラベリング +```yaml +# .github/workflows/pr-labeler.yml +name: PR Labeler +on: + pull_request: + types: [opened, edited, synchronize] + +jobs: + label: + runs-on: ubuntu-latest + steps: + - uses: actions/labeler@v4 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + configuration-path: .github/labeler.yml +``` + +```yaml +# .github/labeler.yml +"area:frontend": + - "src/components/**/*" + - "src/pages/**/*" + - "**/*.vue" + - "**/*.jsx" + +"area:backend": + - "api/**/*" + - "server/**/*" + - "**/*.py" + - "**/*.go" + +"area:database": + - "migrations/**/*" + - "**/*.sql" + - "database/**/*" + +"size:small": + - any: ['**/*'] + count-within: 1..10 + +"size:medium": + - any: ['**/*'] + count-within: 11..50 + +"size:large": + - any: ['**/*'] + count-within: 51.. +``` + +#### レビュアー自動アサイン +```yaml +# .github/workflows/assign-reviewers.yml +name: Auto Assign Reviewers +on: + pull_request: + types: [opened, ready_for_review] + +jobs: + assign: + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v6 + with: + script: | + const pr = context.payload.pull_request; + const files = await github.rest.pulls.listFiles({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: pr.number + }); + + let reviewers = []; + const fileNames = files.data.map(f => f.filename); + + // ファイルパスベースでレビュアー決定 + if (fileNames.some(f => f.includes('frontend'))) { + reviewers.push('frontend-lead'); + } + if (fileNames.some(f => f.includes('backend'))) { + reviewers.push('backend-lead'); + } + if (fileNames.some(f => f.includes('security'))) { + reviewers.push('security-team'); + } + + if (reviewers.length > 0) { + await github.rest.pulls.requestReviewers({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: pr.number, + reviewers: reviewers + }); + } +``` + +--- + +## 5. 自動化とCI/CD連携 + +### ⚡ GitHub Actions との統合 + +#### 包括的なPRチェックワークフロー +```yaml +# .github/workflows/pr-checks.yml +name: PR Quality Checks + +on: + pull_request: + branches: [main, develop] + types: [opened, synchronize, reopened] + +jobs: + code-quality: + name: Code Quality + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Lint check + run: npm run lint + + - name: Type check + run: npm run type-check + + - name: Format check + run: npm run format:check + + security-scan: + name: Security Scan + runs-on: ubuntu-latest + permissions: + security-events: write + steps: + - uses: actions/checkout@v4 + + - name: Run Trivy vulnerability scanner + uses: aquasecurity/trivy-action@master + with: + scan-type: 'fs' + scan-ref: '.' + format: 'sarif' + output: 'trivy-results.sarif' + + - name: Upload Trivy scan results + uses: github/codeql-action/upload-sarif@v2 + with: + sarif_file: 'trivy-results.sarif' + + test: + name: Test Suite + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [16, 18, 20] + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Run tests + run: npm run test:coverage + + - name: Upload coverage reports + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + + e2e-test: + name: E2E Tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Install Playwright + run: npx playwright install --with-deps + + - name: Run E2E tests + run: npm run test:e2e + + - name: Upload test results + uses: actions/upload-artifact@v3 + if: failure() + with: + name: playwright-report + path: playwright-report/ + + performance: + name: Performance Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Build project + run: npm run build + + - name: Run Lighthouse CI + uses: treosh/lighthouse-ci-action@v9 + with: + configPath: './lighthouserc.js' + uploadArtifacts: true + temporaryPublicStorage: true +``` + +### 📊 PR品質メトリクス + +#### 自動品質レポート生成 +```yaml +# .github/workflows/pr-metrics.yml +name: PR Metrics +on: + pull_request: + types: [closed] + +jobs: + metrics: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Calculate PR metrics + uses: actions/github-script@v6 + with: + script: | + const pr = context.payload.pull_request; + + // PR統計の計算 + const createdAt = new Date(pr.created_at); + const mergedAt = new Date(pr.merged_at); + const timeTaken = (mergedAt - createdAt) / (1000 * 60 * 60); // 時間 + + // ファイル変更数の取得 + const files = await github.rest.pulls.listFiles({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: pr.number + }); + + const stats = { + prNumber: pr.number, + title: pr.title, + author: pr.user.login, + timeToMerge: timeTaken.toFixed(2), + filesChanged: files.data.length, + additions: pr.additions, + deletions: pr.deletions, + reviewers: pr.requested_reviewers.map(r => r.login), + comments: pr.review_comments + pr.comments + }; + + // 統計をIssueコメントに投稿 + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pr.number, + body: `## 📊 PR Statistics + + - **⏱️ Time to merge**: ${stats.timeToMerge} hours + - **📁 Files changed**: ${stats.filesChanged} + - **➕ Additions**: ${stats.additions} + - **➖ Deletions**: ${stats.deletions} + - **💬 Comments**: ${stats.comments} + - **👥 Reviewers**: ${stats.reviewers.join(', ') || 'None'} + + Thanks @${stats.author} for the contribution! 🎉` + }); +``` + +--- + +## 6. 外部ツールとの比較 + +### 📊 機能比較マトリックス + +| 機能 | GitHub PR | GitLab MR | Bitbucket PR | Azure DevOps | 備考 | +|------|-----------|-----------|--------------|--------------|------| +| **基本PR機能** | ✅ | ✅ | ✅ | ✅ | 全て対応 | +| **Draft PR** | ✅ | ✅ | ❌ | ✅ | Bitbucketは部分対応 | +| **Suggested Changes** | ✅ | ✅ | ❌ | ⚠️ | GitHubが最も使いやすい | +| **自動マージ** | ✅ | ✅ | ✅ | ✅ | 条件設定の柔軟性はGitHubが優秀 | +| **ブランチ保護** | ✅ | ✅ | ✅ | ✅ | 設定の詳細度はGitHubが最高 | +| **レビュアー自動アサイン** | ✅ | ✅ | ✅ | ✅ | CODEOWNERS機能 | +| **CI/CD統合** | ✅ | ✅ | ✅ | ✅ | Actions統合はシームレス | +| **コメント機能** | ✅ | ✅ | ✅ | ✅ | GitHub が最も直感的 | +| **モバイル対応** | ✅ | ⚠️ | ⚠️ | ⚠️ | GitHubモバイルアプリが優秀 | +| **API充実度** | ✅ | ✅ | ⚠️ | ✅ | GitHub REST/GraphQL API | + +### 🔄 GitLab からの移行 + +#### 主要な差分と移行方法 + +**GitLab MR → GitHub PR 移行マッピング** +```markdown +### 機能対応表 + +| GitLab MR | GitHub PR | 移行方法 | +|-----------|-----------|----------| +| Merge Request | Pull Request | 1:1対応 | +| Draft MR | Draft PR | 機能同等 | +| WIP: タイトル | Draft PR | Draftフラグ使用 | +| Approval Rules | Branch Protection | 保護ルールで設定 | +| Merge Trains | Auto-merge | キューイング機能 | +| Squash Commits | Squash and merge | マージオプション | +| Cherry-pick | GitHub CLI | `gh pr checkout` + `git cherry-pick` | +``` + +#### 移行スクリプト例 +```python +# gitlab_to_github_pr_migration.py +import requests +import json + +class GitLabToGitHubMigrator: + def __init__(self, gitlab_token, github_token, gitlab_project_id, github_repo): + self.gitlab_token = gitlab_token + self.github_token = github_token + self.gitlab_project_id = gitlab_project_id + self.github_repo = github_repo + + def migrate_merge_requests(self): + # GitLab MRsを取得 + gitlab_mrs = self.fetch_gitlab_mrs() + + for mr in gitlab_mrs: + if mr['state'] == 'merged': + # マージ済みMRの情報を記録 + self.record_merged_mr(mr) + elif mr['state'] == 'opened': + # オープンMRをGitHub PRとして再作成 + self.create_github_pr(mr) + + def create_github_pr(self, gitlab_mr): + github_pr_data = { + 'title': gitlab_mr['title'], + 'head': gitlab_mr['source_branch'], + 'base': gitlab_mr['target_branch'], + 'body': self.convert_description(gitlab_mr['description']), + 'draft': gitlab_mr['work_in_progress'] + } + + # GitHub API でPR作成 + response = requests.post( + f"https://api.github.com/repos/{self.github_repo}/pulls", + headers={"Authorization": f"token {self.github_token}"}, + json=github_pr_data + ) + + if response.status_code == 201: + print(f"Created PR: {github_pr_data['title']}") + else: + print(f"Failed to create PR: {response.text}") +``` + +### ⚖️ コスト・効率性比較 + +#### 年間運用コスト比較(100人チーム想定) +```markdown +### プラットフォーム別コスト分析 + +#### GitHub Enterprise +- **ライセンス**: $21,000/年 +- **運用工数**: 最小限(SaaS) +- **学習コスト**: 低(広く普及) +- **合計**: $25,000/年 + +#### GitLab Premium +- **ライセンス**: $19,000/年 +- **運用工数**: 中程度(自己管理オプション) +- **学習コスト**: 中(機能豊富) +- **合計**: $28,000/年 + +#### Bitbucket Premium +- **ライセンス**: $15,000/年 +- **運用工数**: 中程度 +- **学習コスト**: 中 +- **合計**: $22,000/年 + +### 効率性指標 + +| 指標 | GitHub | GitLab | Bitbucket | +|------|--------|--------|-----------| +| **PR作成時間** | 30秒 | 45秒 | 60秒 | +| **レビュー効率** | 95% | 90% | 85% | +| **マージ時間** | 10秒 | 15秒 | 20秒 | +| **モバイル対応** | 100% | 70% | 60% | +``` + +--- + +## 🎓 実践演習 + +### 演習1: 完全なPRワークフロー実践 +1. **Issue作成** - 機能要求の詳細化 +2. **ブランチ作成** - 適切な命名規則 +3. **実装** - コード品質を意識 +4. **Draft PR作成** - 早期フィードバック取得 +5. **CI/CD実行** - 自動テスト・品質チェック +6. **レビュー対応** - 建設的な議論 +7. **マージ** - 適切な戦略選択 + +### 演習2: 高度なレビュー機能活用 +1. **Suggested Changes** - 具体的修正提案 +2. **CODEOWNERS** - 自動レビュアーアサイン +3. **ブランチ保護** - 品質ゲート設定 +4. **自動化** - ラベリング・通知設定 + +### 演習3: チーム用PR規約策定 +1. **PRテンプレート** - チーム標準化 +2. **レビューガイドライン** - 観点の明確化 +3. **マージルール** - 戦略の統一 +4. **品質メトリクス** - 継続改善指標 + +--- + +## 🔗 関連リソース + +### 公式ドキュメント +- [GitHub Pull Requests](https://docs.github.com/en/pull-requests) +- [Code Review Best Practices](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests) +- [Branch Protection Rules](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests) + +### ツール・拡張機能 +- [GitHub CLI](https://cli.github.com/) +- [GitHub Desktop](https://desktop.github.com/) +- [GitHub Mobile](https://github.com/mobile) +- [VS Code GitHub Pull Requests](https://marketplace.visualstudio.com/items?itemName=GitHub.vscode-pull-request-github) + +### 参考記事 +- [Conventional Commits](https://www.conventionalcommits.org/) +- [Git Flow vs GitHub Flow](https://lucamezzalira.com/2014/03/10/git-flow-vs-github-flow/) +- [Code Review Best Practices](https://smartbear.com/learn/code-review/best-practices-for-peer-code-review/) + +--- + +## 📝 まとめ + +GitHub Pull Request機能を効果的に活用することで: + +✅ **高品質なコード** - 体系的なレビュープロセスによる品質向上 +✅ **チーム協調** - 透明性のある開発プロセス +✅ **知識共有** - レビューを通じた技術的成長 +✅ **効率化** - 自動化による作業時間短縮 +✅ **外部ツール不要** - GitHub標準機能のみで企業レベルの開発プロセス + +## 🔗 関連ガイド + +- **前のステップ**: [Issues管理編](02-issues-management.md) - タスク管理とプロジェクト追跡 +- **次のステップ**: [GitHub Projects編](04-github-projects.md) - プロジェクト管理の最適化 +- **基礎知識**: [リポジトリ基礎編](01-repository-basics.md) - ブランチ管理とタグ運用 +- **総合ガイド**: [GitHub完全活用ガイド](../GITHUB_COMPLETE_GUIDE.md) - 全機能の詳細解説 + +## 📖 学習フロー + +```mermaid +graph LR + A[リポジトリ基礎] --> B[Issues管理] + B --> C[Pull Request] + C --> D[GitHub Projects] + D --> E[完全活用] + + style A fill:#f3e5f5 + style B fill:#f3e5f5 + style C fill:#e1f5fe + style D fill:#e8f5e8 + style E fill:#fce4ec +``` + +次は[GitHub Projects編](04-github-projects.md)で、プロジェクト管理の最適化を学習しましょう。 \ No newline at end of file diff --git a/features/04-github-projects.md b/features/04-github-projects.md new file mode 100644 index 0000000..be880aa --- /dev/null +++ b/features/04-github-projects.md @@ -0,0 +1,756 @@ +--- +layout: default +title: "GitHub Projects完全ガイド" +description: "アジャイル開発のためのプロジェクト管理とGitHub Projects V2完全活用法" +--- + +# 📋 GitHub Projects - アジャイル開発のためのプロジェクト管理 + +GitHub Projects V2を活用して、Jira・Trello・Asanaなどの外部ツールに依存しない、統合されたプロジェクト管理環境を構築する完全ガイド。Issues・Pull Requestsとシームレスに連携し、開発から運用まで一元管理を実現します。 + +## 🎯 学習目標 + +- GitHub Projects V2の全機能理解と実践的活用 +- アジャイル開発手法(スクラム・カンバン)の実装 +- 外部プロジェクト管理ツールからの完全移行 +- 自動化によるプロジェクト運用効率化 +- チーム協働とステークホルダー管理の最適化 + +## 📚 目次 + +1. [GitHub Projects V2 概要](#1-github-projects-v2-概要) +2. [プロジェクト作成と基本設定](#2-プロジェクト作成と基本設定) +3. [ビューとワークフローの設計](#3-ビューとワークフローの設計) +4. [カスタムフィールドと自動化](#4-カスタムフィールドと自動化) +5. [アジャイル手法の実装](#5-アジャイル手法の実装) +6. [外部ツールからの移行](#6-外部ツールからの移行) + +--- + +## 1. GitHub Projects V2 概要 + +### 🚀 従来版との主要な違い + +#### Projects V2 の革新的機能 +```markdown +### V1 → V2 進化ポイント + +#### データ構造 +- **V1**: カード形式(制限的) +- **V2**: テーブル形式(柔軟性) + +#### カスタマイズ性 +- **V1**: 基本的なカラム移動のみ +- **V2**: カスタムフィールド・フィルタ・グループ化 + +#### 自動化 +- **V1**: 限定的なワークフロー +- **V2**: 高度な自動化ルール + +#### ビュー機能 +- **V1**: カンバンビューのみ +- **V2**: カンバン・テーブル・ロードマップ・ガントチャート + +#### スコープ +- **V1**: リポジトリレベル +- **V2**: 組織・個人・複数リポジトリ対応 +``` + +### 📊 外部ツールとの機能比較 + +| 機能 | GitHub Projects V2 | Jira | Trello | Asana | Linear | 備考 | +|------|-------------------|------|-------|-------|--------|------| +| **カンバンボード** | ✅ | ✅ | ✅ | ✅ | ✅ | 全て対応 | +| **ガントチャート** | ✅ | ✅ | ❌ | ✅ | ❌ | Projects V2で新対応 | +| **スプリント管理** | ✅ | ✅ | ⚠️ | ✅ | ✅ | カスタムフィールドで実現 | +| **バーンダウンチャート** | ⚠️ | ✅ | ❌ | ⚠️ | ✅ | APIで実現可能 | +| **カスタムフィールド** | ✅ | ✅ | ❌ | ✅ | ✅ | 高い柔軟性 | +| **自動化** | ✅ | ✅ | ⚠️ | ✅ | ✅ | GitHub Actions連携 | +| **レポート機能** | ⚠️ | ✅ | ❌ | ✅ | ✅ | Insights・API活用 | +| **コード連携** | ✅ | ⚠️ | ❌ | ❌ | ⚠️ | 最も強力 | +| **コスト(100人)** | $0-2,100 | $7,000 | $5,000 | $12,000 | $8,000 | 圧倒的にコスト効率良い | + +--- + +## 2. プロジェクト作成と基本設定 + +### 🛠️ プロジェクト初期設定 + +#### 新規プロジェクト作成 +```bash +# GitHub CLI でプロジェクト作成 +gh project create --title "Product Development Q1 2024" \ + --body "Q1期の製品開発プロジェクト管理" + +# または Web UI で作成 +# https://github.com/users/USERNAME/projects/new +# または組織: https://github.com/orgs/ORGANIZATION/projects/new +``` + +#### 基本設定の最適化 +```markdown +### プロジェクト基本情報 + +#### 必須設定項目 +- **プロジェクト名**: 明確で検索しやすい名前 +- **説明**: 目的・スコープ・期間を明記 +- **可視性**: Private(機密) / Public(オープンソース) +- **所有者**: 個人 / 組織 +- **README**: プロジェクトの詳細情報 + +#### 推奨README構成 +```markdown +# Product Development Q1 2024 + +## 🎯 プロジェクト概要 +Q1期間中の製品開発における機能開発・バグ修正・リリース管理 + +## 📅 期間 +2024年1月1日 - 2024年3月31日 + +## 👥 チーム構成 +- **Product Manager**: @product-lead +- **Tech Lead**: @tech-lead +- **Frontend**: @frontend-team +- **Backend**: @backend-team +- **QA**: @qa-team + +## 🎯 主要マイルストーン +- [ ] Alpha版リリース (1/31) +- [ ] Beta版リリース (2/28) +- [ ] 本番リリース (3/31) + +## 📊 成功指標 +- 機能完成率: 95%以上 +- バグ解決率: 100% +- リリース予定遵守率: 90%以上 +``` + +### 🔗 リポジトリとの連携設定 + +#### 複数リポジトリの統合管理 +```bash +# プロジェクトにリポジトリを追加 +gh project item-create PROJECT_ID \ + --owner OWNER \ + --repo REPO_NAME + +# 複数リポジトリの一括追加例 +REPOS=("frontend-app" "backend-api" "mobile-app" "documentation") +for repo in "${REPOS[@]}"; do + gh project item-create $PROJECT_ID --owner $OWNER --repo $repo +done +``` + +--- + +## 3. ビューとワークフローの設計 + +### 📊 多角的ビューの構築 + +#### 1. カンバンビュー(日常業務用) +```markdown +### カンバン列設計 + +#### 基本フロー +📋 **Backlog** → 🏗️ **Ready** → 🔄 **In Progress** → 👀 **Review** → ✅ **Done** + +#### 詳細ステータス定義 +- **Backlog**: 優先順位付け待ち・要件未確定 +- **Ready**: 開発可能・担当者アサイン済み +- **In Progress**: 実装中・ブロック状況の監視 +- **Review**: PR作成済み・レビュー待ち +- **Done**: マージ完了・検証済み + +#### 高度な列設定 +- **Ice Box**: 将来検討・低優先度アイデア +- **Blocked**: 外部依存・技術的課題で停止中 +- **Waiting**: 顧客フィードバック・承認待ち +- **Deployed**: 本番環境デプロイ完了 +``` + +#### 2. テーブルビュー(詳細管理用) +```markdown +### カスタムフィールド設計 + +#### 必須フィールド +- **Status**: Single select(Backlog, Ready, In Progress, Review, Done) +- **Priority**: Single select(Critical, High, Medium, Low) +- **Size**: Single select(XS, S, M, L, XL) +- **Epic**: Text(関連するエピック名) +- **Sprint**: Single select(Sprint 1, Sprint 2, ...) +- **Assignee**: People(担当者) +- **Due Date**: Date(期限) +- **Story Points**: Number(見積もりポイント) + +#### 発展フィールド +- **Component**: Multi-select(Frontend, Backend, Mobile, API) +- **Customer Impact**: Single select(High, Medium, Low, None) +- **Technical Debt**: Single select(Yes, No) +- **Risk Level**: Single select(High, Medium, Low) +- **Reviewer**: People(レビュー担当者) +``` + +#### 3. ロードマップビュー(戦略的計画用) +```markdown +### 時系列での進捗可視化 + +#### 設定項目 +- **X軸**: 時間軸(週・月・四半期) +- **Y軸**: エピック・チーム・コンポーネント +- **マーカー**: マイルストーン・リリース予定日 +- **色分け**: 優先度・ステータス・担当チーム + +#### 活用シーン +- **エグゼクティブレビュー**: 経営陣への進捗報告 +- **リリース計画**: 機能リリースのタイムライン +- **リソース配分**: チーム間の作業バランス確認 +- **依存関係管理**: ブロッカーの可視化 +``` + +### 🔄 ワークフロー自動化の設計 + +#### Issue → Project 自動追加 +```yaml +# .github/workflows/add-to-project.yml +name: Add Issue to Project +on: + issues: + types: [opened, labeled] + +jobs: + add-to-project: + runs-on: ubuntu-latest + steps: + - name: Add to project + uses: actions/add-to-project@v0.4.0 + with: + project-url: https://github.com/users/USERNAME/projects/1 + github-token: ${{ secrets.ADD_TO_PROJECT_TOKEN }} + labeled: bug,enhancement,feature +``` + +#### ステータス自動更新 +```yaml +# .github/workflows/update-project-status.yml +name: Update Project Status +on: + pull_request: + types: [opened, closed, merged] + +jobs: + update-status: + runs-on: ubuntu-latest + steps: + - name: Update status on PR + uses: actions/github-script@v6 + with: + script: | + const pr = context.payload.pull_request; + + // PRの状態に応じてプロジェクトアイテムのステータスを更新 + let newStatus; + if (pr.state === 'open') { + newStatus = 'Review'; + } else if (pr.merged) { + newStatus = 'Done'; + } else if (pr.state === 'closed') { + newStatus = 'Backlog'; + } + + // GraphQL APIでプロジェクトアイテムを更新 + const query = ` + mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $value: String!) { + updateProjectV2ItemFieldValue( + input: { + projectId: $projectId + itemId: $itemId + fieldId: $fieldId + value: { singleSelectOptionId: $value } + } + ) { + projectV2Item { + id + } + } + } + `; + + // 実際の更新処理 + // 注:projectId, itemId, fieldIdは環境に応じて設定 +``` + +--- + +## 4. カスタムフィールドと自動化 + +### 🎛️ 高度なカスタマイズ + +#### スクラム開発用フィールド設定 +```markdown +### スクラム特化カスタムフィールド + +#### ストーリー管理 +- **User Story**: Text(ユーザーストーリー記述) +- **Acceptance Criteria**: Text(受け入れ条件) +- **Story Points**: Number(1, 2, 3, 5, 8, 13, 21) +- **Business Value**: Single select(High, Medium, Low) + +#### スプリント管理 +- **Sprint**: Single select(Current, Next, Future, Backlog) +- **Sprint Goal**: Text(スプリント目標) +- **Velocity**: Number(チームの開発速度) +- **Burndown**: Number(残作業量) + +#### 品質管理 +- **Definition of Done**: Checkbox(完了条件チェックリスト) +- **Test Coverage**: Number(テストカバレッジ%) +- **Code Review Status**: Single select(Pending, Approved, Changes Requested) +- **QA Status**: Single select(Not Started, In Progress, Passed, Failed) +``` + +#### カンバン開発用フィールド設定 +```markdown +### カンバン特化カスタムフィールド + +#### フロー管理 +- **WIP Limit**: Number(作業中上限数) +- **Cycle Time**: Number(開始から完了までの日数) +- **Lead Time**: Number(要求から完了までの日数) +- **Flow Efficiency**: Number(実作業時間の割合%) + +#### 継続改善 +- **Blocker Reason**: Text(ブロック理由) +- **Improvement Suggestion**: Text(改善提案) +- **Retrospective Item**: Checkbox(振り返り対象) +- **Customer Feedback**: Text(顧客からのフィードバック) +``` + +### 🤖 自動化ルールの実装 + +#### 複雑な条件分岐自動化 +```yaml +# .github/workflows/project-automation.yml +name: Advanced Project Automation +on: + issues: + types: [opened, edited, labeled, assigned] + pull_request: + types: [opened, closed, review_requested, review_submitted] + +jobs: + project-automation: + runs-on: ubuntu-latest + steps: + - name: Advanced Automation Logic + uses: actions/github-script@v6 + with: + script: | + const { data: projects } = await github.rest.projects.listForUser({ + username: context.repo.owner + }); + + const projectId = projects.find(p => p.name === 'Development Board')?.id; + if (!projectId) return; + + // 複雑な条件分岐処理 + const event = context.eventName; + const action = context.payload.action; + + switch(event) { + case 'issues': + await handleIssueEvent(action, context.payload.issue); + break; + case 'pull_request': + await handlePREvent(action, context.payload.pull_request); + break; + } + + async function handleIssueEvent(action, issue) { + // 優先度に応じた自動アサイン + if (issue.labels.some(l => l.name === 'priority:critical')) { + await github.rest.issues.addAssignees({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue.number, + assignees: ['team-lead'] + }); + } + + // 見積もりポイントの自動設定 + let storyPoints = 3; // デフォルト + if (issue.labels.some(l => l.name === 'size:small')) storyPoints = 1; + if (issue.labels.some(l => l.name === 'size:large')) storyPoints = 8; + + // プロジェクトアイテムのフィールド更新 + // 注:実際のGraphQL実装が必要 + } + + async function handlePREvent(action, pr) { + if (action === 'opened') { + // PR作成時:関連Issueのステータスを「Review」に更新 + const linkedIssues = extractLinkedIssues(pr.body); + for (const issueNumber of linkedIssues) { + // ステータス更新処理 + } + } + } + + function extractLinkedIssues(prBody) { + const regex = /(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s+#(\d+)/gi; + const matches = [...prBody.matchAll(regex)]; + return matches.map(match => parseInt(match[1])); + } +``` + +--- + +## 5. アジャイル手法の実装 + +### 🏃‍♂️ スクラム手法の完全実装 + +#### スプリント計画・実行・振り返り + +**スプリント計画ビューの設定** +```markdown +### Sprint Planning View 設定 + +#### フィルタ設定 +- **Status**: Backlog, Ready +- **Sprint**: Current, Next +- **Story Points**: 1-21(見積もり済み) + +#### グループ化 +- **Primary**: Epic(機能群別) +- **Secondary**: Priority(優先度別) + +#### ソート順 +1. Priority(Critical → High → Medium → Low) +2. Business Value(High → Medium → Low) +3. Story Points(小 → 大) + +#### 表示カラム +- Title, Status, Assignee, Story Points, Sprint, Due Date +``` + +**スプリント実行中のデイリースタンドアップ支援** +```markdown +### Daily Standup Dashboard + +#### 今日の作業ビュー +- **フィルタ**: Status = "In Progress", Assignee = "@me" +- **表示**: 昨日完了・今日予定・ブロッカー情報 + +#### チーム全体の進捗ビュー +- **グループ化**: Assignee(担当者別) +- **色分け**: ステータス別(緑=順調、黄=注意、赤=遅延) +- **アラート**: 期限超過・長期停滞アイテム + +#### ブロッカー監視ビュー +- **フィルタ**: Labels contains "blocked" +- **ソート**: 作成日(古い順) +- **アクション**: 担当者への通知・エスカレーション +``` + +#### スプリントレトロスペクティブ +```markdown +### Sprint Retrospective Template + +#### 振り返り観点 +- **Keep**: 継続すべきこと +- **Problem**: 改善が必要なこと +- **Try**: 次スプリントで試すこと + +#### メトリクス収集 +- **Velocity**: 完了ストーリーポイント +- **Burndown**: 日別残作業量推移 +- **Cycle Time**: 平均完了時間 +- **Bug Rate**: 不具合発生率 + +#### 改善アクション +- 特定された問題の対策アイテム作成 +- プロセス改善のためのタスク追加 +- 次スプリントでの実験項目設定 +``` + +### 📊 カンバン手法の実装 + +#### 継続的フロー最適化 + +**WIP制限の設定と監視** +```markdown +### WIP Limits by Column + +#### 推奨設定(5人チーム) +- **Ready**: 10アイテム(バックログの充実) +- **In Progress**: 5アイテム(チーム人数と同じ) +- **Review**: 3アイテム(迅速なレビュー) +- **Blocked**: 制限なし(問題の可視化) + +#### 監視とアラート +- WIP超過時の自動通知 +- 長期滞留アイテムの検出 +- フロー効率の計測・レポート +``` + +**累積フロー図(CFD)の作成** +```python +# cfd_generator.py - Cumulative Flow Diagram 生成 +import requests +import matplotlib.pyplot as plt +import pandas as pd +from datetime import datetime, timedelta + +class CFDGenerator: + def __init__(self, github_token, project_id): + self.token = github_token + self.project_id = project_id + + def generate_cfd(self, days=30): + """過去30日間の累積フロー図を生成""" + end_date = datetime.now() + start_date = end_date - timedelta(days=days) + + daily_data = [] + current_date = start_date + + while current_date <= end_date: + # その日のステータス別アイテム数を取得 + status_counts = self.get_status_counts_for_date(current_date) + daily_data.append({ + 'date': current_date, + **status_counts + }) + current_date += timedelta(days=1) + + df = pd.DataFrame(daily_data) + + # 累積フロー図の描画 + plt.figure(figsize=(12, 8)) + statuses = ['Done', 'Review', 'In Progress', 'Ready', 'Backlog'] + colors = ['#28a745', '#ffc107', '#007bff', '#6c757d', '#dc3545'] + + for i, status in enumerate(statuses): + plt.fill_between(df['date'], + df[status] if i == 0 else df[statuses[:i+1]].sum(axis=1), + df[statuses[:i]].sum(axis=1) if i > 0 else 0, + color=colors[i], alpha=0.7, label=status) + + plt.xlabel('Date') + plt.ylabel('Number of Items') + plt.title('Cumulative Flow Diagram') + plt.legend() + plt.xticks(rotation=45) + plt.tight_layout() + plt.savefig('cfd.png', dpi=300, bbox_inches='tight') + + return df + + def get_status_counts_for_date(self, date): + """指定日のステータス別アイテム数を取得""" + # GitHub GraphQL API を使用してプロジェクトデータを取得 + # 実装の詳細は省略(実際のAPI呼び出しが必要) + return { + 'Backlog': 15, + 'Ready': 8, + 'In Progress': 5, + 'Review': 3, + 'Done': 25 + } + +# 使用例 +cfd = CFDGenerator(github_token="your_token", project_id="project_id") +data = cfd.generate_cfd() +print("CFD generated successfully!") +``` + +--- + +## 6. 外部ツールからの移行 + +### 🔄 Jira からの移行 + +#### 完全移行チェックリスト +```markdown +### Phase 1: データマッピング設計(1週間) + +#### Jiraフィールド → GitHub Projects フィールド対応 +- **Issue Type** → **Labels**(bug, feature, story, epic) +- **Priority** → **Priority**(Critical, High, Medium, Low) +- **Status** → **Status**(Backlog, In Progress, Done等) +- **Assignee** → **Assignee**(ユーザーマッピング必要) +- **Epic Link** → **Epic**(カスタムテキストフィールド) +- **Story Points** → **Story Points**(カスタム数値フィールド) +- **Sprint** → **Sprint**(カスタム選択フィールド) +- **Components** → **Labels**(複数ラベルで対応) + +### Phase 2: 移行ツール開発(2週間) + +#### 自動移行スクリプト +```python +# jira_to_github_projects.py +import requests +import json +from jira import JIRA + +class JiraToGitHubMigrator: + def __init__(self, jira_url, jira_user, jira_token, github_token, github_project_id): + self.jira = JIRA(server=jira_url, basic_auth=(jira_user, jira_token)) + self.github_token = github_token + self.project_id = github_project_id + + def migrate_project(self, jira_project_key): + """Jiraプロジェクト全体を移行""" + # 1. Jira Issuesを取得 + issues = self.jira.search_issues(f'project={jira_project_key}', maxResults=1000) + + # 2. GitHub Issues/Project Itemsを作成 + for issue in issues: + github_issue = self.create_github_issue(issue) + self.add_to_project(github_issue['number']) + + def create_github_issue(self, jira_issue): + """Jira Issue を GitHub Issue に変換""" + # フィールドマッピング + title = jira_issue.fields.summary + body = self.convert_description(jira_issue.fields.description) + labels = self.map_labels(jira_issue.fields.issuetype, jira_issue.fields.priority) + + issue_data = { + 'title': title, + 'body': body, + 'labels': labels + } + + # GitHub API で Issue 作成 + response = requests.post( + f'https://api.github.com/repos/{self.repo}/issues', + headers={'Authorization': f'token {self.github_token}'}, + json=issue_data + ) + + return response.json() +``` + +### Phase 3: チーム教育・並行運用(2週間) + +#### 教育プログラム +- **ハンズオン研修**: GitHub Projects V2操作方法 +- **ワークショップ**: アジャイルプロセスの再設計 +- **QAセッション**: 移行に関する疑問解決 +- **ドキュメント**: 新しいプロセスの標準化 + +### Phase 4: 完全移行・Jira停止(1週間) + +#### 移行完了基準 +- [ ] 全データ移行完了・検証済み +- [ ] チーム全員が新プロセスに習熟 +- [ ] 自動化・インテグレーション動作確認 +- [ ] パフォーマンス・可用性確認 +- [ ] バックアップ・ロールバック手順準備 +``` + +### 📊 コスト効果分析 + +#### 移行前後の比較(100人チーム・年間) +```markdown +### 導入・運用コスト比較 + +#### Jira(移行前) +- **ライセンス費用**: $7,000/年 +- **管理・運用**: 1人 × 20% = $20,000/年 +- **教育・サポート**: $5,000/年 +- **カスタマイズ**: $10,000/年 +- **合計**: $42,000/年 + +#### GitHub Projects V2(移行後) +- **ライセンス費用**: $0(GitHub Pro に含まれる) +- **管理・運用**: 1人 × 5% = $5,000/年 +- **教育・サポート**: $2,000/年(初年度のみ) +- **カスタマイズ**: $3,000/年(自動化開発) +- **合計**: $10,000/年 + +### ROI計算 +- **年間削減額**: $32,000 +- **移行コスト**: $15,000(一時費用) +- **投資回収期間**: 5.6ヶ月 +- **3年間総節約額**: $81,000 +``` + +--- + +## 🎓 実践演習 + +### 演習1: スクラムプロジェクト構築 +1. **プロジェクト作成** - チーム用スクラムボード +2. **カスタムフィールド設定** - ストーリーポイント・スプリント +3. **自動化ルール** - Issue→Project追加・ステータス更新 +4. **レポートビュー** - スプリント進捗・ベロシティ + +### 演習2: カンバンフロー最適化 +1. **フロー設計** - WIP制限・フロー効率 +2. **メトリクス収集** - サイクルタイム・リードタイム +3. **継続改善** - ボトルネック特定・プロセス改善 +4. **可視化** - 累積フロー図・バーンアップチャート + +### 演習3: 外部ツール移行 +1. **現状分析** - 既存ツールの機能・データ調査 +2. **移行計画** - フェーズ別移行ロードマップ +3. **データマッピング** - フィールド・ワークフロー対応 +4. **並行運用** - リスク軽減・段階的移行 + +--- + +## 🔗 関連リソース + +### 公式ドキュメント +- [GitHub Projects Documentation](https://docs.github.com/en/issues/planning-and-tracking-with-projects) +- [Projects V2 GraphQL API](https://docs.github.com/en/graphql/reference/objects#projectv2) +- [GitHub Projects Best Practices](https://github.blog/2022-07-27-planning-next-to-your-code-github-projects-is-now-generally-available/) + +### 移行・活用ツール +- [Jira to GitHub Issues Migration](https://github.com/marketplace/actions/jira-to-github-issues) +- [Projects V2 CLI](https://cli.github.com/manual/gh_project) +- [GitHub Projects API Scripts](https://github.com/github/projects-scripts) + +### アジャイル手法参考資料 +- [Scrum Guide](https://scrumguides.org/) +- [Kanban Method](https://www.atlassian.com/agile/kanban) +- [Agile Metrics](https://www.agilealliance.org/agile101/guide-to-agile-metrics/) + +--- + +## 📝 まとめ + +GitHub Projects V2を効果的に活用することで: + +✅ **統合された開発環境** - コードとプロジェクト管理の一元化 +✅ **コスト大幅削減** - 外部ツールライセンス費用の削減 +✅ **チーム生産性向上** - シームレスなワークフローと自動化 +✅ **柔軟なプロセス適応** - スクラム・カンバン・独自手法に対応 +✅ **データドリブン改善** - メトリクス収集と継続的最適化 + +次は実際のプロジェクトでGitHub Projects V2を活用し、チームの開発プロセスを最適化しましょう! + +## 🔗 関連ガイド + +- **前のステップ**: [Pull Request編](03-pull-requests.md) - コードレビュープロセス最適化 +- **基礎知識**: [Issues管理編](02-issues-management.md) - タスク管理の基礎 +- **さらに基礎**: [リポジトリ基礎編](01-repository-basics.md) - 基本的なGit操作 +- **総合ガイド**: [GitHub完全活用ガイド](../GITHUB_COMPLETE_GUIDE.md) - 全機能の詳細解説 + +## 📖 学習フロー + +```mermaid +graph LR + A[リポジトリ基礎] --> B[Issues管理] + B --> C[Pull Request] + C --> D[GitHub Projects] + D --> E[完全活用] + + style A fill:#f3e5f5 + style B fill:#f3e5f5 + style C fill:#f3e5f5 + style D fill:#e1f5fe + style E fill:#e8f5e8 +``` \ No newline at end of file diff --git a/index.md b/index.md index ef8f2e2..2ec4652 100644 --- a/index.md +++ b/index.md @@ -51,14 +51,14 @@ description: "外部ツールに依存せず、GitHub一つで開発業務を完

Jiraを完全代替するタスク管理システム

- +

🔄 Pull Request

-

効率的なコードレビューフロー(準備中)

+

効率的なコードレビューフローとマージ戦略

- +

📋 GitHub Projects

-

アジャイル開発のためのプロジェクト管理(準備中)

+

アジャイル開発のためのプロジェクト管理

From 59b60ace065ec2f58550d23ad6f85fe0991ac6e3 Mon Sep 17 00:00:00 2001 From: marketing-shibata50 Date: Sun, 20 Jul 2025 13:22:23 +0900 Subject: [PATCH 02/18] feat: add comprehensive GitHub guides expansion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🆕 New Guides Added: - GitHub Actions complete guide (CI/CD automation) - GitHub Security comprehensive guide (enterprise security) - GitHub Pages detailed guide (website publishing) 🔗 Navigation Improvements: - Updated index.md with all 7 guides - Added cross-navigation between all guides - Enhanced learning paths for different user types - Comprehensive learning flow diagrams 📚 Content Highlights: - Jenkins/CircleCI migration strategies - Enterprise security best practices - WordPress to GitHub Pages migration - Advanced automation workflows - Complete external tool replacements 🎯 User Experience: - Role-based learning recommendations - Consistent navigation structure - Progressive learning paths - Cross-reference linking 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- features/01-repository-basics.md | 3 + features/02-issues-management.md | 2 + features/03-pull-requests.md | 2 + features/04-github-projects.md | 2 + features/05-github-actions.md | 1681 +++++++++++++++++++++++++++ features/06-github-security.md | 1368 ++++++++++++++++++++++ features/07-github-pages.md | 1838 ++++++++++++++++++++++++++++++ index.md | 38 +- 8 files changed, 4924 insertions(+), 10 deletions(-) create mode 100644 features/05-github-actions.md create mode 100644 features/06-github-security.md create mode 100644 features/07-github-pages.md diff --git a/features/01-repository-basics.md b/features/01-repository-basics.md index 5701b53..31e6878 100644 --- a/features/01-repository-basics.md +++ b/features/01-repository-basics.md @@ -415,6 +415,9 @@ GitHub リポジトリの基本機能をマスターすることで: - **次のステップ**: [Issues管理編](02-issues-management.md) - プロジェクト管理の基礎 - **さらに学習**: [Pull Request編](03-pull-requests.md) - コードレビューフロー - **プロジェクト管理**: [GitHub Projects編](04-github-projects.md) - アジャイル開発手法 +- **自動化**: [GitHub Actions編](05-github-actions.md) - CI/CD自動化 +- **セキュリティ**: [GitHub Security編](06-github-security.md) - 総合セキュリティ +- **Web公開**: [GitHub Pages編](07-github-pages.md) - Webサイト・ドキュメント - **総合ガイド**: [GitHub完全活用ガイド](../GITHUB_COMPLETE_GUIDE.md) - 全機能の詳細解説 ## 📖 学習フロー diff --git a/features/02-issues-management.md b/features/02-issues-management.md index 160628a..0fd3d21 100644 --- a/features/02-issues-management.md +++ b/features/02-issues-management.md @@ -595,6 +595,8 @@ GitHub Issues を効果的に活用することで: - **前のステップ**: [リポジトリ基礎編](01-repository-basics.md) - GitHub の基本操作 - **次のステップ**: [Pull Request編](03-pull-requests.md) - コードレビューとマージプロセス - **さらに学習**: [GitHub Projects編](04-github-projects.md) - アジャイル開発プロジェクト管理 +- **自動化**: [GitHub Actions編](05-github-actions.md) - Issue自動化・CI/CD +- **セキュリティ**: [GitHub Security編](06-github-security.md) - セキュリティ課題管理 - **総合ガイド**: [GitHub完全活用ガイド](../GITHUB_COMPLETE_GUIDE.md) - 全機能の詳細解説 ## 📖 学習フロー diff --git a/features/03-pull-requests.md b/features/03-pull-requests.md index 3f0a36c..d7029fd 100644 --- a/features/03-pull-requests.md +++ b/features/03-pull-requests.md @@ -913,6 +913,8 @@ GitHub Pull Request機能を効果的に活用することで: - **前のステップ**: [Issues管理編](02-issues-management.md) - タスク管理とプロジェクト追跡 - **次のステップ**: [GitHub Projects編](04-github-projects.md) - プロジェクト管理の最適化 - **基礎知識**: [リポジトリ基礎編](01-repository-basics.md) - ブランチ管理とタグ運用 +- **自動化**: [GitHub Actions編](05-github-actions.md) - PR自動化・CI/CD +- **セキュリティ**: [GitHub Security編](06-github-security.md) - セキュアな開発プロセス - **総合ガイド**: [GitHub完全活用ガイド](../GITHUB_COMPLETE_GUIDE.md) - 全機能の詳細解説 ## 📖 学習フロー diff --git a/features/04-github-projects.md b/features/04-github-projects.md index be880aa..87a805e 100644 --- a/features/04-github-projects.md +++ b/features/04-github-projects.md @@ -735,8 +735,10 @@ GitHub Projects V2を効果的に活用することで: ## 🔗 関連ガイド - **前のステップ**: [Pull Request編](03-pull-requests.md) - コードレビュープロセス最適化 +- **次のステップ**: [GitHub Actions編](05-github-actions.md) - プロジェクト自動化・CI/CD - **基礎知識**: [Issues管理編](02-issues-management.md) - タスク管理の基礎 - **さらに基礎**: [リポジトリ基礎編](01-repository-basics.md) - 基本的なGit操作 +- **セキュリティ**: [GitHub Security編](06-github-security.md) - プロジェクトセキュリティ - **総合ガイド**: [GitHub完全活用ガイド](../GITHUB_COMPLETE_GUIDE.md) - 全機能の詳細解説 ## 📖 学習フロー diff --git a/features/05-github-actions.md b/features/05-github-actions.md new file mode 100644 index 0000000..6ab26e3 --- /dev/null +++ b/features/05-github-actions.md @@ -0,0 +1,1681 @@ +--- +layout: default +title: "GitHub Actions完全ガイド" +description: "Jenkins・CircleCI代替のCI/CD自動化とGitHub Actions完全活用法" +--- + +# ⚡ GitHub Actions - 完全なCI/CD自動化 + +GitHub Actionsを活用して、Jenkins・CircleCI・GitLab CI・Azure DevOpsなどの外部CI/CDツールに依存しない、統合された自動化環境を構築する完全ガイド。コードのビルド・テスト・デプロイから、複雑なワークフロー自動化まで網羅します。 + +## 🎯 学習目標 + +- GitHub Actions の全機能理解と実践的活用 +- 外部CI/CDツールからの完全移行戦略 +- セキュアで効率的なワークフロー設計 +- 高度な自動化とDevOps実践 +- コスト最適化と運用効率向上 + +## 📚 目次 + +1. [GitHub Actions 基本概念](#1-github-actions-基本概念) +2. [CI/CDパイプライン構築](#2-cicdパイプライン構築) +3. [高度なワークフロー設計](#3-高度なワークフロー設計) +4. [セキュリティ・シークレット管理](#4-セキュリティシークレット管理) +5. [外部ツールからの移行](#5-外部ツールからの移行) +6. [運用最適化・監視](#6-運用最適化監視) + +--- + +## 1. GitHub Actions 基本概念 + +### 🏗️ アーキテクチャ理解 + +#### 核心コンポーネント +```yaml +# GitHub Actions の基本構造 +Workflow (ワークフロー) +├── Events (イベント) - トリガー条件 +├── Jobs (ジョブ) - 実行単位 +│ ├── Steps (ステップ) - 個別タスク +│ │ ├── Actions (アクション) - 再利用可能な処理 +│ │ └── Commands (コマンド) - シェル実行 +│ └── Runner (ランナー) - 実行環境 +├── Secrets (シークレット) - 機密情報 +└── Environment (環境) - デプロイメント設定 +``` + +#### 基本ワークフロー例 +```yaml +# .github/workflows/basic-ci.yml +name: Basic CI Pipeline + +# イベント定義 +on: + push: + branches: [main, develop] + pull_request: + branches: [main] + schedule: + - cron: '0 2 * * 1' # 毎週月曜 2時 + +# グローバル環境変数 +env: + NODE_VERSION: '18' + CACHE_KEY: node-modules + +jobs: + # ジョブ1: コード品質チェック + quality-check: + name: Code Quality + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Lint check + run: npm run lint + + - name: Type check + run: npm run type-check + + - name: Security audit + run: npm audit --audit-level high + + # ジョブ2: テスト実行 + test: + name: Test Suite + runs-on: ubuntu-latest + needs: quality-check + + strategy: + matrix: + node-version: [16, 18, 20] + os: [ubuntu-latest, windows-latest, macos-latest] + + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Run tests + run: npm run test:coverage + env: + CI: true + + - name: Upload coverage + uses: codecov/codecov-action@v3 + if: matrix.node-version == 18 && matrix.os == 'ubuntu-latest' + with: + token: ${{ secrets.CODECOV_TOKEN }} +``` + +### 🎛️ イベントトリガーの活用 + +#### 包括的なトリガー設定 +```yaml +# 高度なイベント設定例 +on: + # プッシュイベント + push: + branches: + - main + - 'release/**' + - 'hotfix/**' + paths: + - 'src/**' + - 'package.json' + - '.github/workflows/**' + tags: + - 'v*' + + # プルリクエストイベント + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + branches: [main, develop] + paths-ignore: + - 'docs/**' + - '*.md' + + # Issue イベント + issues: + types: [opened, labeled, assigned] + + # リリースイベント + release: + types: [published, prereleased] + + # スケジュール実行 + schedule: + - cron: '0 2 * * 1-5' # 平日 2時 + - cron: '0 10 * * 6' # 土曜 10時 + + # 手動実行 + workflow_dispatch: + inputs: + environment: + description: 'Deployment environment' + required: true + default: 'staging' + type: choice + options: + - staging + - production + debug: + description: 'Enable debug logging' + required: false + default: false + type: boolean + version: + description: 'Version to deploy' + required: false + type: string + + # 他のワークフローからの呼び出し + workflow_call: + inputs: + config-path: + required: true + type: string + secrets: + api-key: + required: true +``` + +--- + +## 2. CI/CDパイプライン構築 + +### 🔄 フルスタックCI/CDパイプライン + +#### Node.js アプリケーション用 +```yaml +# .github/workflows/nodejs-cicd.yml +name: Node.js CI/CD Pipeline + +on: + push: + branches: [main, develop] + pull_request: + branches: [main] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + # ステージ1: ビルド・テスト + build-and-test: + name: Build and Test + runs-on: ubuntu-latest + + outputs: + version: ${{ steps.version.outputs.version }} + image-digest: ${{ steps.build.outputs.digest }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'npm' + + - name: Generate version + id: version + run: | + if [[ $GITHUB_REF == refs/tags/* ]]; then + VERSION=${GITHUB_REF#refs/tags/} + else + VERSION=$(git describe --tags --always --dirty) + fi + echo "version=$VERSION" >> $GITHUB_OUTPUT + + - name: Install dependencies + run: npm ci + + - name: Run linting + run: npm run lint + + - name: Run type checking + run: npm run type-check + + - name: Run unit tests + run: npm run test:unit -- --coverage + + - name: Run integration tests + run: npm run test:integration + env: + DATABASE_URL: postgresql://postgres:postgres@localhost:5432/test + + - name: Build application + run: npm run build + env: + NODE_ENV: production + VERSION: ${{ steps.version.outputs.version }} + + - name: Upload build artifacts + uses: actions/upload-artifact@v3 + with: + name: build-artifacts + path: | + dist/ + package.json + package-lock.json + retention-days: 7 + + # ステージ2: セキュリティスキャン + security-scan: + name: Security Scanning + runs-on: ubuntu-latest + needs: build-and-test + + permissions: + security-events: write + + steps: + - uses: actions/checkout@v4 + + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: build-artifacts + + - name: Run Trivy vulnerability scanner + uses: aquasecurity/trivy-action@master + with: + scan-type: 'fs' + scan-ref: '.' + format: 'sarif' + output: 'trivy-results.sarif' + + - name: Upload Trivy results + uses: github/codeql-action/upload-sarif@v2 + with: + sarif_file: 'trivy-results.sarif' + + - name: OWASP Dependency Check + uses: dependency-check/Dependency-Check_Action@main + with: + project: 'my-project' + path: '.' + format: 'SARIF' + args: > + --enableRetired + --enableExperimental + --failOnCVSS 7 + + # ステージ3: E2Eテスト + e2e-tests: + name: E2E Tests + runs-on: ubuntu-latest + needs: build-and-test + + services: + postgres: + image: postgres:15 + env: + POSTGRES_PASSWORD: postgres + POSTGRES_DB: testdb + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + + redis: + image: redis:7 + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 6379:6379 + + steps: + - uses: actions/checkout@v4 + + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: build-artifacts + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Setup test database + run: | + npm run db:migrate + npm run db:seed + env: + DATABASE_URL: postgresql://postgres:postgres@localhost:5432/testdb + + - name: Install Playwright + run: npx playwright install --with-deps + + - name: Start application + run: | + npm start & + npx wait-on http://localhost:3000 --timeout 60000 + env: + NODE_ENV: test + DATABASE_URL: postgresql://postgres:postgres@localhost:5432/testdb + REDIS_URL: redis://localhost:6379 + + - name: Run E2E tests + run: npm run test:e2e + env: + BASE_URL: http://localhost:3000 + + - name: Upload test results + uses: actions/upload-artifact@v3 + if: failure() + with: + name: e2e-results + path: | + test-results/ + playwright-report/ + + # ステージ4: Dockerイメージビルド + build-image: + name: Build Docker Image + runs-on: ubuntu-latest + needs: [build-and-test, security-scan] + if: github.event_name == 'push' + + permissions: + contents: read + packages: write + + outputs: + image: ${{ steps.image.outputs.image }} + digest: ${{ steps.build.outputs.digest }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: build-artifacts + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=sha,prefix={{branch}}- + + - name: Build and push image + id: build + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + build-args: | + VERSION=${{ needs.build-and-test.outputs.version }} + + - name: Output image + id: image + run: echo "image=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.build-and-test.outputs.version }}" >> $GITHUB_OUTPUT + + # ステージ5: ステージング環境デプロイ + deploy-staging: + name: Deploy to Staging + runs-on: ubuntu-latest + needs: [build-image, e2e-tests] + if: github.ref == 'refs/heads/develop' + + environment: + name: staging + url: https://staging.example.com + + steps: + - name: Deploy to staging + uses: azure/webapps-deploy@v2 + with: + app-name: 'my-app-staging' + publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE_STAGING }} + images: ${{ needs.build-image.outputs.image }} + + - name: Run smoke tests + run: | + curl -f https://staging.example.com/health || exit 1 + curl -f https://staging.example.com/api/status || exit 1 + + # ステージ6: 本番環境デプロイ + deploy-production: + name: Deploy to Production + runs-on: ubuntu-latest + needs: [build-image, deploy-staging] + if: github.ref == 'refs/heads/main' + + environment: + name: production + url: https://example.com + + steps: + - name: Deploy to production + uses: azure/webapps-deploy@v2 + with: + app-name: 'my-app-production' + publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE_PRODUCTION }} + images: ${{ needs.build-image.outputs.image }} + + - name: Run production smoke tests + run: | + curl -f https://example.com/health || exit 1 + curl -f https://example.com/api/status || exit 1 + + - name: Notify deployment + uses: 8398a7/action-slack@v3 + with: + status: ${{ job.status }} + channel: '#deployments' + webhook_url: ${{ secrets.SLACK_WEBHOOK }} + if: always() +``` + +### 🐍 Python アプリケーション用 +```yaml +# .github/workflows/python-cicd.yml +name: Python CI/CD Pipeline + +on: + push: + branches: [main, develop] + pull_request: + branches: [main] + +jobs: + test: + name: Test Suite + runs-on: ubuntu-latest + + strategy: + matrix: + python-version: ['3.8', '3.9', '3.10', '3.11'] + + services: + postgres: + image: postgres:15 + env: + POSTGRES_PASSWORD: postgres + POSTGRES_DB: testdb + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Cache dependencies + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install -r requirements-dev.txt + + - name: Lint with flake8 + run: | + flake8 src/ tests/ --count --select=E9,F63,F7,F82 --show-source --statistics + flake8 src/ tests/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + + - name: Type check with mypy + run: mypy src/ + + - name: Test with pytest + run: | + pytest tests/ --cov=src/ --cov-report=xml --cov-report=html + env: + DATABASE_URL: postgresql://postgres:postgres@localhost:5432/testdb + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + file: ./coverage.xml + flags: unittests + name: codecov-umbrella + + security: + name: Security Scan + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install safety bandit + + - name: Run safety check + run: safety check + + - name: Run bandit security check + run: bandit -r src/ -f json -o bandit-report.json + + - name: Upload security scan results + uses: actions/upload-artifact@v3 + if: failure() + with: + name: security-reports + path: bandit-report.json + + build-and-deploy: + name: Build and Deploy + runs-on: ubuntu-latest + needs: [test, security] + if: github.ref == 'refs/heads/main' + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Build package + run: | + python -m pip install --upgrade pip build + python -m build + + - name: Deploy to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.PYPI_API_TOKEN }} +``` + +--- + +## 3. 高度なワークフロー設計 + +### 🔄 再利用可能ワークフロー + +#### 共通CI/CDテンプレート +```yaml +# .github/workflows/reusable-ci.yml +name: Reusable CI Workflow + +on: + workflow_call: + inputs: + node-version: + required: false + type: string + default: '18' + environment: + required: false + type: string + default: 'development' + run-e2e: + required: false + type: boolean + default: false + secrets: + NPM_TOKEN: + required: false + CODECOV_TOKEN: + required: false + outputs: + build-version: + description: "Built application version" + value: ${{ jobs.build.outputs.version }} + artifact-name: + description: "Build artifact name" + value: ${{ jobs.build.outputs.artifact-name }} + +jobs: + build: + name: Build and Test + runs-on: ubuntu-latest + + outputs: + version: ${{ steps.version.outputs.version }} + artifact-name: ${{ steps.artifact.outputs.name }} + + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.node-version }} + cache: 'npm' + registry-url: 'https://registry.npmjs.org' + + - name: Generate version + id: version + run: | + VERSION=$(date +%Y%m%d)-$(git rev-parse --short HEAD) + echo "version=$VERSION" >> $GITHUB_OUTPUT + + - name: Install dependencies + run: npm ci + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Run tests + run: npm run test:coverage + + - name: Upload coverage + if: secrets.CODECOV_TOKEN != '' + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Build application + run: npm run build + env: + NODE_ENV: ${{ inputs.environment }} + VERSION: ${{ steps.version.outputs.version }} + + - name: Create artifact + id: artifact + run: | + ARTIFACT_NAME="build-${{ steps.version.outputs.version }}" + echo "name=$ARTIFACT_NAME" >> $GITHUB_OUTPUT + + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: ${{ steps.artifact.outputs.name }} + path: dist/ + + e2e-tests: + name: E2E Tests + runs-on: ubuntu-latest + needs: build + if: inputs.run-e2e + + steps: + - uses: actions/checkout@v4 + + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: ${{ needs.build.outputs.artifact-name }} + path: dist/ + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.node-version }} + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Install Playwright + run: npx playwright install --with-deps + + - name: Run E2E tests + run: npm run test:e2e +``` + +#### ワークフローの呼び出し +```yaml +# .github/workflows/main-ci.yml +name: Main CI Pipeline + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + ci: + name: Continuous Integration + uses: ./.github/workflows/reusable-ci.yml + with: + node-version: '18' + environment: 'production' + run-e2e: true + secrets: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + + deploy: + name: Deploy Application + runs-on: ubuntu-latest + needs: ci + if: github.ref == 'refs/heads/main' + + steps: + - name: Download build artifacts + uses: actions/download-artifact@v3 + with: + name: ${{ needs.ci.outputs.artifact-name }} + + - name: Deploy to production + run: | + echo "Deploying version ${{ needs.ci.outputs.build-version }}" + # デプロイメントロジック +``` + +### 🎯 コンポジットアクション + +#### カスタムアクション作成 +```yaml +# .github/actions/setup-app/action.yml +name: 'Setup Application' +description: 'Setup Node.js application with caching and dependencies' + +inputs: + node-version: + description: 'Node.js version to use' + required: false + default: '18' + cache-dependency-path: + description: 'Path to dependency file' + required: false + default: 'package-lock.json' + install-command: + description: 'Command to install dependencies' + required: false + default: 'npm ci' + +outputs: + cache-hit: + description: 'Cache hit status' + value: ${{ steps.cache.outputs.cache-hit }} + node-version: + description: 'Installed Node.js version' + value: ${{ steps.setup-node.outputs.node-version }} + +runs: + using: 'composite' + steps: + - name: Setup Node.js + id: setup-node + uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.node-version }} + cache: 'npm' + cache-dependency-path: ${{ inputs.cache-dependency-path }} + + - name: Cache node modules + id: cache + uses: actions/cache@v3 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles(inputs.cache-dependency-path) }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Install dependencies + shell: bash + run: ${{ inputs.install-command }} + env: + NODE_AUTH_TOKEN: ${{ env.NODE_AUTH_TOKEN }} + + - name: Verify installation + shell: bash + run: | + echo "Node.js version: $(node --version)" + echo "npm version: $(npm --version)" + echo "Dependencies installed successfully" +``` + +#### アクションの使用 +```yaml +# ワークフローでの使用例 +steps: + - uses: actions/checkout@v4 + + - name: Setup application + uses: ./.github/actions/setup-app + with: + node-version: '18' + install-command: 'npm ci --production' + + - name: Build application + run: npm run build +``` + +--- + +## 4. セキュリティ・シークレット管理 + +### 🔐 シークレット管理戦略 + +#### 環境別シークレット設定 +```yaml +# セキュリティベストプラクティス +name: Secure Deployment + +on: + push: + branches: [main] + +jobs: + deploy: + name: Secure Deployment + runs-on: ubuntu-latest + + # 環境の設定 + environment: + name: production + url: https://example.com + + steps: + - uses: actions/checkout@v4 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ vars.AWS_REGION }} + role-to-assume: ${{ secrets.AWS_ROLE_ARN }} + role-session-name: GitHubActions + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 + + - name: Build and push Docker image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: ${{ vars.ECR_REPOSITORY }} + IMAGE_TAG: ${{ github.sha }} + run: | + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + + - name: Deploy to ECS + run: | + aws ecs update-service \ + --cluster ${{ vars.ECS_CLUSTER }} \ + --service ${{ vars.ECS_SERVICE }} \ + --force-new-deployment +``` + +#### OIDC プロバイダー認証 +```yaml +# クラウドプロバイダーとのOIDC認証 +name: OIDC Authentication + +on: + push: + branches: [main] + +permissions: + id-token: write # OIDC トークン取得に必要 + contents: read + +jobs: + deploy-aws: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: arn:aws:iam::123456789012:role/GitHubActionsRole + role-session-name: GitHubActions + aws-region: us-east-1 + + - name: Deploy to AWS + run: | + aws s3 sync ./dist s3://${{ vars.S3_BUCKET }}/ + + deploy-azure: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + + - name: Deploy to Azure + run: | + az webapp deployment source config-zip \ + --resource-group ${{ vars.AZURE_RESOURCE_GROUP }} \ + --name ${{ vars.AZURE_APP_NAME }} \ + --src ./dist.zip +``` + +### 🛡️ セキュリティスキャン自動化 + +#### 包括的セキュリティチェック +```yaml +# .github/workflows/security-scan.yml +name: Security Scanning + +on: + push: + branches: [main, develop] + pull_request: + branches: [main] + schedule: + - cron: '0 3 * * 1' # 毎週月曜 3時 + +permissions: + security-events: write + contents: read + +jobs: + code-scanning: + name: Code Scanning + runs-on: ubuntu-latest + + strategy: + matrix: + language: ['javascript', 'python'] + + steps: + - uses: actions/checkout@v4 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + queries: security-extended,security-and-quality + + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" + + dependency-scanning: + name: Dependency Scanning + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Run Trivy vulnerability scanner + uses: aquasecurity/trivy-action@master + with: + scan-type: 'fs' + scan-ref: '.' + format: 'sarif' + output: 'trivy-results.sarif' + + - name: Upload Trivy scan results + uses: github/codeql-action/upload-sarif@v2 + with: + sarif_file: 'trivy-results.sarif' + + - name: Snyk security scan + uses: snyk/actions/node@master + env: + SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} + with: + args: --severity-threshold=high --sarif-file-output=snyk.sarif + + - name: Upload Snyk results + uses: github/codeql-action/upload-sarif@v2 + with: + sarif_file: snyk.sarif + + container-scanning: + name: Container Scanning + runs-on: ubuntu-latest + if: github.event_name == 'push' + + steps: + - uses: actions/checkout@v4 + + - name: Build Docker image + run: docker build -t test-image . + + - name: Run Trivy container scan + uses: aquasecurity/trivy-action@master + with: + image-ref: 'test-image' + format: 'sarif' + output: 'trivy-container.sarif' + + - name: Upload container scan results + uses: github/codeql-action/upload-sarif@v2 + with: + sarif_file: 'trivy-container.sarif' + + secret-scanning: + name: Secret Scanning + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: TruffleHog OSS + uses: trufflesecurity/trufflehog@main + with: + path: ./ + base: main + head: HEAD + extra_args: --debug --only-verified +``` + +--- + +## 5. 外部ツールからの移行 + +### 🔄 Jenkins からの移行 + +#### Jenkinsfile → GitHub Actions 変換例 +```groovy +// 元のJenkinsfile +pipeline { + agent any + + environment { + NODE_VERSION = '18' + DOCKER_REGISTRY = 'myregistry.com' + } + + stages { + stage('Checkout') { + steps { + checkout scm + } + } + + stage('Build') { + steps { + sh 'npm ci' + sh 'npm run build' + } + } + + stage('Test') { + parallel { + stage('Unit Tests') { + steps { + sh 'npm run test:unit' + } + post { + always { + publishTestResults testResultsPattern: 'test-results.xml' + } + } + } + + stage('E2E Tests') { + steps { + sh 'npm run test:e2e' + } + } + } + } + + stage('Deploy') { + when { + branch 'main' + } + steps { + sh 'docker build -t $DOCKER_REGISTRY/myapp:$BUILD_NUMBER .' + sh 'docker push $DOCKER_REGISTRY/myapp:$BUILD_NUMBER' + } + } + } + + post { + always { + cleanWs() + } + failure { + mail to: 'team@example.com', + subject: "Build Failed: ${env.JOB_NAME} - ${env.BUILD_NUMBER}", + body: "Build failed. Check console output." + } + } +} +``` + +```yaml +# 変換後のGitHub Actions +name: Migrated from Jenkins + +on: + push: + branches: [main, develop] + pull_request: + branches: [main] + +env: + NODE_VERSION: '18' + DOCKER_REGISTRY: 'myregistry.com' + +jobs: + build: + name: Build Application + runs-on: ubuntu-latest + + outputs: + build-number: ${{ steps.build-number.outputs.number }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Generate build number + id: build-number + run: echo "number=${{ github.run_number }}" >> $GITHUB_OUTPUT + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Build application + run: npm run build + + - name: Upload build artifacts + uses: actions/upload-artifact@v3 + with: + name: build-artifacts + path: dist/ + + test: + name: Test Suite + runs-on: ubuntu-latest + needs: build + + strategy: + matrix: + test-type: [unit, e2e] + + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: build-artifacts + path: dist/ + + - name: Run tests + run: npm run test:${{ matrix.test-type }} + + - name: Publish test results + uses: dorny/test-reporter@v1 + if: success() || failure() + with: + name: ${{ matrix.test-type }} Tests + path: test-results.xml + reporter: jest-junit + + deploy: + name: Deploy Application + runs-on: ubuntu-latest + needs: [build, test] + if: github.ref == 'refs/heads/main' + + steps: + - uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to registry + uses: docker/login-action@v3 + with: + registry: ${{ env.DOCKER_REGISTRY }} + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ env.DOCKER_REGISTRY }}/myapp:${{ needs.build.outputs.build-number }} + + - name: Notify on failure + if: failure() + uses: 8398a7/action-slack@v3 + with: + status: failure + channel: '#alerts' + webhook_url: ${{ secrets.SLACK_WEBHOOK }} + message: | + Build Failed: ${{ github.workflow }} - ${{ github.run_number }} + Check the console output for details. +``` + +### 📊 移行比較表 + +| 機能 | Jenkins | CircleCI | GitLab CI | GitHub Actions | 備考 | +|------|---------|----------|-----------|----------------|------| +| **セットアップ** | 複雑 | 簡単 | 中程度 | 最も簡単 | GitHub統合 | +| **設定ファイル** | Groovy | YAML | YAML | YAML | GitHub Actionsが最も直感的 | +| **並列実行** | ✅ | ✅ | ✅ | ✅ | matrix戦略が優秀 | +| **キャッシュ** | プラグイン | ✅ | ✅ | ✅ | 設定が最もシンプル | +| **シークレット管理** | プラグイン | ✅ | ✅ | ✅ | 環境別管理が優秀 | +| **コスト(中規模)** | 高 | 中 | 中 | 低 | 無料枠が大きい | +| **学習コスト** | 高 | 中 | 中 | 低 | 広く普及 | +| **拡張性** | 高 | 中 | 高 | 高 | Marketplaceが充実 | + +--- + +## 6. 運用最適化・監視 + +### 📊 パフォーマンス最適化 + +#### 高速ビルド戦略 +```yaml +# .github/workflows/optimized-ci.yml +name: Optimized CI Pipeline + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + changes: + name: Detect Changes + runs-on: ubuntu-latest + outputs: + frontend: ${{ steps.changes.outputs.frontend }} + backend: ${{ steps.changes.outputs.backend }} + docs: ${{ steps.changes.outputs.docs }} + steps: + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v2 + id: changes + with: + filters: | + frontend: + - 'frontend/**' + - 'package.json' + backend: + - 'backend/**' + - 'requirements.txt' + docs: + - 'docs/**' + - '*.md' + + frontend-ci: + name: Frontend CI + runs-on: ubuntu-latest + needs: changes + if: needs.changes.outputs.frontend == 'true' + + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js with cache + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'npm' + cache-dependency-path: 'frontend/package-lock.json' + + - name: Restore node_modules cache + uses: actions/cache@v3 + with: + path: frontend/node_modules + key: ${{ runner.os }}-nodemodules-${{ hashFiles('frontend/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-nodemodules- + + - name: Install dependencies + run: npm ci --prefix frontend + + - name: Parallel build and test + run: | + npm run build --prefix frontend & + npm run test --prefix frontend & + wait + + backend-ci: + name: Backend CI + runs-on: ubuntu-latest + needs: changes + if: needs.changes.outputs.backend == 'true' + + steps: + - uses: actions/checkout@v4 + + - name: Setup Python with cache + uses: actions/setup-python@v4 + with: + python-version: '3.11' + cache: 'pip' + cache-dependency-path: 'backend/requirements.txt' + + - name: Install dependencies + run: | + cd backend + pip install -r requirements.txt + + - name: Run tests + run: | + cd backend + pytest --maxfail=1 --disable-warnings -q + + docs-check: + name: Documentation Check + runs-on: ubuntu-latest + needs: changes + if: needs.changes.outputs.docs == 'true' + + steps: + - uses: actions/checkout@v4 + + - name: Check documentation + run: | + # ドキュメントの軽量チェック + echo "Checking documentation..." + # 実際のドキュメントビルド・リンクチェック等 +``` + +### 📈 モニタリング・メトリクス + +#### 詳細メトリクス収集 +```yaml +# .github/workflows/metrics-collection.yml +name: CI/CD Metrics Collection + +on: + workflow_run: + workflows: ["Main CI", "Deploy Pipeline"] + types: [completed] + +jobs: + collect-metrics: + name: Collect CI/CD Metrics + runs-on: ubuntu-latest + + steps: + - name: Collect workflow metrics + uses: actions/github-script@v6 + with: + script: | + const workflowRun = context.payload.workflow_run; + + // ワークフロー実行時間の計算 + const startTime = new Date(workflowRun.created_at); + const endTime = new Date(workflowRun.updated_at); + const duration = (endTime - startTime) / 1000; // 秒 + + // メトリクスデータの作成 + const metrics = { + workflow_name: workflowRun.name, + status: workflowRun.conclusion, + duration_seconds: duration, + commit_sha: workflowRun.head_sha, + branch: workflowRun.head_branch, + trigger_event: workflowRun.event, + run_number: workflowRun.run_number, + timestamp: workflowRun.created_at + }; + + // メトリクスをログ出力 + console.log('CI/CD Metrics:', JSON.stringify(metrics, null, 2)); + + // 外部監視システムに送信(例:DataDog、Prometheus等) + if (process.env.DATADOG_API_KEY) { + await fetch('https://api.datadoghq.com/api/v1/series', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'DD-API-KEY': process.env.DATADOG_API_KEY + }, + body: JSON.stringify({ + series: [{ + metric: 'github_actions.workflow.duration', + points: [[Math.floor(Date.now() / 1000), duration]], + tags: [ + `workflow:${workflowRun.name}`, + `status:${workflowRun.conclusion}`, + `branch:${workflowRun.head_branch}` + ] + }] + }) + }); + } + env: + DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }} + + - name: Generate weekly report + if: github.event.schedule == '0 9 * * 1' # 毎週月曜日 + uses: actions/github-script@v6 + with: + script: | + // 過去1週間のワークフロー実行データを取得 + const { data: runs } = await github.rest.actions.listWorkflowRunsForRepo({ + owner: context.repo.owner, + repo: context.repo.repo, + per_page: 100, + created: `>=${new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString()}` + }); + + // メトリクス集計 + const metrics = runs.workflow_runs.reduce((acc, run) => { + const duration = (new Date(run.updated_at) - new Date(run.created_at)) / 1000; + + if (!acc[run.name]) { + acc[run.name] = { + total_runs: 0, + successful_runs: 0, + failed_runs: 0, + total_duration: 0, + avg_duration: 0 + }; + } + + acc[run.name].total_runs++; + acc[run.name].total_duration += duration; + + if (run.conclusion === 'success') { + acc[run.name].successful_runs++; + } else if (run.conclusion === 'failure') { + acc[run.name].failed_runs++; + } + + acc[run.name].avg_duration = acc[run.name].total_duration / acc[run.name].total_runs; + + return acc; + }, {}); + + // レポート生成 + let report = '# GitHub Actions Weekly Report\n\n'; + + for (const [workflow, data] of Object.entries(metrics)) { + const successRate = ((data.successful_runs / data.total_runs) * 100).toFixed(2); + + report += `## ${workflow}\n`; + report += `- **Total Runs**: ${data.total_runs}\n`; + report += `- **Success Rate**: ${successRate}%\n`; + report += `- **Average Duration**: ${Math.round(data.avg_duration)}s\n`; + report += `- **Failed Runs**: ${data.failed_runs}\n\n`; + } + + // Issueとしてレポートを投稿 + await github.rest.issues.create({ + owner: context.repo.owner, + repo: context.repo.repo, + title: `Weekly CI/CD Report - ${new Date().toISOString().split('T')[0]}`, + body: report, + labels: ['metrics', 'weekly-report'] + }); +``` + +--- + +## 🎓 実践演習 + +### 演習1: フルスタックCI/CDパイプライン構築 +1. **多言語対応** - Node.js + Python のモノレポ +2. **並列実行** - 言語別の独立したジョブ +3. **条件分岐** - 変更検知による最適化 +4. **成果物管理** - アーティファクトの効率的な受け渡し + +### 演習2: セキュリティファーストパイプライン +1. **コード解析** - CodeQL・Semgrep統合 +2. **依存関係スキャン** - Snyk・Trivy活用 +3. **シークレット検知** - TruffleHog導入 +4. **コンテナセキュリティ** - イメージスキャン自動化 + +### 演習3: 外部ツール移行プロジェクト +1. **現状分析** - 既存CI/CDの機能・設定調査 +2. **移行戦略** - 段階的移行計画立案 +3. **並行運用** - リスク軽減・検証期間設定 +4. **完全移行** - 旧システム停止・運用移管 + +--- + +## 🔗 関連リソース + +### 公式ドキュメント +- [GitHub Actions Documentation](https://docs.github.com/en/actions) +- [Workflow Syntax](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions) +- [GitHub Actions Marketplace](https://github.com/marketplace?type=actions) + +### 移行・活用ツール +- [Jenkins to GitHub Actions Migration](https://github.com/actions/importer) +- [Actions Toolkit](https://github.com/actions/toolkit) +- [Runner Images](https://github.com/actions/runner-images) + +### 監視・最適化ツール +- [ActionLint](https://github.com/rhymond/actionlint) - ワークフロー検証 +- [GitHub Actions Usage Metrics](https://github.com/github/actions-usage-metrics) +- [Workflow Optimization Guide](https://docs.github.com/en/actions/using-workflows/about-workflows#using-starter-workflows) + +--- + +## 📝 まとめ + +GitHub Actions を効果的に活用することで: + +✅ **外部ツール不要** - Jenkins・CircleCIからの完全移行 +✅ **コスト大幅削減** - インフラ・ライセンス費用の最適化 +✅ **統合開発環境** - コードとCI/CDの一元管理 +✅ **高度な自動化** - セキュリティ・品質・デプロイの自動化 +✅ **スケーラビリティ** - 企業レベルの大規模開発対応 + +次は[GitHub Security編](06-github-security.md)で、総合的なセキュリティ対策を学習しましょう。 + +## 🔗 関連ガイド + +- **前のステップ**: [GitHub Projects編](04-github-projects.md) - プロジェクト管理の最適化 +- **次のステップ**: [GitHub Security編](06-github-security.md) - 総合的なセキュリティ対策 +- **さらに学習**: [GitHub Pages編](07-github-pages.md) - Webサイト・ドキュメント公開 +- **基礎知識**: [Pull Request編](03-pull-requests.md) - CI/CD連携の基礎 +- **総合ガイド**: [GitHub完全活用ガイド](../GITHUB_COMPLETE_GUIDE.md) - 全機能の詳細解説 + +## 📖 学習フロー + +```mermaid +graph LR + A[リポジトリ基礎] --> B[Issues管理] + B --> C[Pull Request] + C --> D[GitHub Projects] + D --> E[GitHub Actions] + E --> F[Security] + F --> G[Pages] + G --> H[完全活用] + + style A fill:#f3e5f5 + style B fill:#f3e5f5 + style C fill:#f3e5f5 + style D fill:#f3e5f5 + style E fill:#e1f5fe + style F fill:#e8f5e8 + style G fill:#fff3e0 + style H fill:#fce4ec +``` \ No newline at end of file diff --git a/features/06-github-security.md b/features/06-github-security.md new file mode 100644 index 0000000..b752aaf --- /dev/null +++ b/features/06-github-security.md @@ -0,0 +1,1368 @@ +--- +layout: default +title: "GitHub Security完全ガイド" +description: "企業レベルのセキュリティ対策とGitHub Advanced Security完全活用法" +--- + +# 🛡️ GitHub Security - 企業レベルの総合セキュリティ対策 + +GitHub標準・Advanced Securityを活用して、Veracode・SonarQube・WhiteSource等の外部セキュリティツールに依存しない、統合されたセキュリティ環境を構築する完全ガイド。コードからインフラまで、開発ライフサイクル全体の包括的なセキュリティ対策を実現します。 + +## 🎯 学習目標 + +- GitHub Security機能の全体理解と戦略的活用 +- Advanced Security(CodeQL・Secret Scanning・Dependabot)の実践的運用 +- セキュリティポリシー・コンプライアンス対応 +- 外部セキュリティツールからの移行戦略 +- インシデント対応・セキュリティ監視の自動化 + +## 📚 目次 + +1. [GitHub Security 概要](#1-github-security-概要) +2. [コードセキュリティ分析](#2-コードセキュリティ分析) +3. [依存関係・脆弱性管理](#3-依存関係脆弱性管理) +4. [シークレット管理・漏洩防止](#4-シークレット管理漏洩防止) +5. [リポジトリ・組織セキュリティ](#5-リポジトリ組織セキュリティ) +6. [コンプライアンス・監査対応](#6-コンプライアンス監査対応) + +--- + +## 1. GitHub Security 概要 + +### 🏗️ GitHub Security アーキテクチャ + +#### セキュリティ機能の階層構造 +```mermaid +graph TB + A[GitHub Security Platform] + + A --> B[Code Security] + A --> C[Infrastructure Security] + A --> D[Access Control] + A --> E[Compliance] + + B --> B1[CodeQL Analysis] + B --> B2[Secret Scanning] + B --> B3[Dependency Review] + + C --> C1[Container Scanning] + C --> C2[Infrastructure as Code] + C --> C3[Supply Chain Security] + + D --> D1[Authentication] + D --> D2[Authorization] + D --> D3[Audit Logging] + + E --> E1[Policy Enforcement] + E --> E2[Compliance Reports] + E --> E3[Risk Assessment] +``` + +#### セキュリティ機能比較 +```markdown +### GitHub Security vs 外部ツール比較 + +| 機能カテゴリ | GitHub (標準) | GitHub Advanced | Veracode | SonarQube | WhiteSource | +|--------------|---------------|-----------------|----------|-----------|-------------| +| **静的解析** | ⚠️ | ✅ | ✅ | ✅ | ❌ | +| **依存関係スキャン** | ✅ | ✅ | ⚠️ | ⚠️ | ✅ | +| **シークレット検知** | ⚠️ | ✅ | ❌ | ❌ | ❌ | +| **コンテナスキャン** | ⚠️ | ✅ | ✅ | ❌ | ⚠️ | +| **ライセンス管理** | ✅ | ✅ | ❌ | ❌ | ✅ | +| **統合性** | ✅ | ✅ | ⚠️ | ⚠️ | ⚠️ | +| **コスト効率** | ✅ | ✅ | ❌ | ⚠️ | ❌ | + +✅ 優秀 ⚠️ 部分対応 ❌ 対応なし +``` + +### 🚀 セキュリティ実装戦略 + +#### 段階的セキュリティ導入計画 +```yaml +# セキュリティ実装ロードマップ + +Phase 1: 基本セキュリティ設定 (Week 1-2) + - 基本認証・認可設定 + - ブランチ保護ルール + - 基本的なDependabot設定 + - シークレット管理の基礎 + +Phase 2: 高度なスキャン機能 (Week 3-4) + - CodeQL分析設定 + - Advanced Secret Scanning + - 依存関係レビュー + - セキュリティアドバイザリ + +Phase 3: 自動化・統合 (Week 5-6) + - CI/CDセキュリティ統合 + - 自動修復ワークフロー + - アラート自動化 + - レポート生成 + +Phase 4: 運用・監視 (Week 7-8) + - セキュリティ監視 + - インシデント対応 + - 継続的改善 + - コンプライアンス対応 +``` + +--- + +## 2. コードセキュリティ分析 + +### 🔍 CodeQL による高度な静的解析 + +#### CodeQL 基本設定 +```yaml +# .github/workflows/codeql-analysis.yml +name: "CodeQL Advanced Analysis" + +on: + push: + branches: [main, develop] + pull_request: + branches: [main] + schedule: + - cron: '30 2 * * 1,3,5' # 月水金 2:30 + +jobs: + analyze: + name: CodeQL Analysis + runs-on: ubuntu-latest + + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: ['javascript', 'python', 'java', 'csharp', 'cpp', 'go'] + # 必要に応じて言語を調整 + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # カスタムクエリの指定 + queries: +security-extended,security-and-quality + # 設定ファイルの指定 + config-file: ./.github/codeql/codeql-config.yml + + # 言語別のビルド設定 + - name: Setup Node.js + if: matrix.language == 'javascript' + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'npm' + + - name: Setup Python + if: matrix.language == 'python' + uses: actions/setup-python@v4 + with: + python-version: '3.11' + cache: 'pip' + + - name: Setup Java + if: matrix.language == 'java' + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + cache: 'maven' + + # 自動ビルド + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # カスタムビルド(必要に応じて) + - name: Custom build + if: matrix.language == 'cpp' + run: | + mkdir build + cd build + cmake .. + make -j$(nproc) + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" + output: codeql-results + upload: true + + - name: Upload SARIF results + if: always() + uses: github/codeql-action/upload-sarif@v2 + with: + sarif_file: codeql-results/${{ matrix.language }}.sarif + category: ${{ matrix.language }} +``` + +#### CodeQL カスタム設定 +```yaml +# .github/codeql/codeql-config.yml +name: "Custom CodeQL Config" + +# 無効化するクエリ +disable-default-queries: false + +# 追加するクエリパック +queries: + - name: security-extended + uses: security-extended + - name: security-and-quality + uses: security-and-quality + - name: custom-queries + uses: ./.github/codeql/custom-queries + +# パス除外設定 +paths-ignore: + - "**/*.test.js" + - "**/*.spec.ts" + - "**/node_modules/**" + - "**/vendor/**" + - "**/dist/**" + - "**/build/**" + - "**/__tests__/**" + - "**/test/**" + - "**/tests/**" + +# パス包含設定(指定したパスのみスキャン) +paths: + - "src/**" + - "api/**" + - "services/**" + +# カスタムビルドコマンド +build-mode: manual +``` + +#### カスタム CodeQL クエリ +```ql +/** + * @name Hardcoded credentials + * @description Finds potential hardcoded passwords or API keys + * @kind problem + * @problem.severity warning + * @security-severity 8.0 + * @precision medium + * @id js/hardcoded-credentials + * @tags security + * external/cwe/cwe-798 + */ + +import javascript + +from StringLiteral str, string value +where + value = str.getValue() and + ( + // パスワードパターン + value.regexpMatch("(?i).*password.*=.*['\"]\\w{8,}['\"].*") or + // APIキーパターン + value.regexpMatch("(?i).*api[_-]?key.*=.*['\"][A-Za-z0-9]{20,}['\"].*") or + // 秘密鍵パターン + value.regexpMatch(".*-----BEGIN (RSA )?PRIVATE KEY-----.*") or + // AWS認証情報パターン + value.regexpMatch("(?i).*aws[_-]?(access[_-]?key|secret).*=.*['\"][A-Z0-9]{20,}['\"].*") + ) and + // 除外パターン + not value.regexpMatch(".*\\$\\{.*\\}.*") and // 環境変数参照 + not value.regexpMatch(".*placeholder.*|.*example.*|.*dummy.*|.*test.*") +select str, "Potential hardcoded credential found: " + value.prefix(50) +``` + +### 🛠️ セキュリティ修復自動化 + +#### 自動修復ワークフロー +```yaml +# .github/workflows/security-auto-fix.yml +name: Security Auto Fix + +on: + schedule: + - cron: '0 3 * * 1' # 毎週月曜 3時 + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + security-events: read + +jobs: + auto-fix: + name: Automated Security Fixes + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'npm' + + - name: Get security alerts + id: alerts + uses: actions/github-script@v6 + with: + script: | + const { data: alerts } = await github.rest.codeScanning.listAlertsForRepo({ + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open', + severity: 'high' + }); + + return alerts.filter(alert => + alert.rule.id.includes('hardcoded-credentials') || + alert.rule.id.includes('sql-injection') || + alert.rule.id.includes('xss') + ); + + - name: Apply automated fixes + if: steps.alerts.outputs.result != '[]' + run: | + # ESLint自動修復 + npm install -g eslint eslint-plugin-security + npx eslint --fix --ext .js,.ts src/ || true + + # Prettier適用 + npm install -g prettier + npx prettier --write src/**/*.{js,ts,jsx,tsx} + + # セキュリティ関連の自動修復 + # 例:console.logの削除、eval()の置換等 + find src/ -name "*.js" -exec sed -i 's/console\.log.*;//g' {} \; + + - name: Update dependencies + run: | + # 脆弱性のある依存関係を更新 + npm audit fix --audit-level high + + # package-lock.jsonの更新 + npm install + + - name: Create Pull Request + if: steps.alerts.outputs.result != '[]' + uses: peter-evans/create-pull-request@v5 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: | + 🔒 Security: Automated security fixes + + - Fixed high-severity CodeQL alerts + - Updated vulnerable dependencies + - Applied ESLint security rules + title: "🔒 Automated Security Fixes" + body: | + ## 🔒 Automated Security Fixes + + This PR contains automated fixes for security issues: + + ### Changes Made + - ✅ Fixed CodeQL high-severity alerts + - ✅ Updated vulnerable dependencies via `npm audit fix` + - ✅ Applied ESLint security rules + - ✅ Code formatting with Prettier + + ### Review Required + Please review these automated changes before merging. + + **Generated by GitHub Actions** 🤖 + branch: security/automated-fixes + delete-branch: true + labels: | + security + automated + high-priority +``` + +--- + +## 3. 依存関係・脆弱性管理 + +### 📦 Dependabot 高度設定 + +#### 包括的なDependabot設定 +```yaml +# .github/dependabot.yml +version: 2 + +updates: + # Node.js パッケージ + - package-ecosystem: "npm" + directory: "/" + schedule: + interval: "daily" + time: "02:00" + timezone: "Asia/Tokyo" + open-pull-requests-limit: 10 + reviewers: + - "security-team" + - "senior-developers" + assignees: + - "team-lead" + labels: + - "dependencies" + - "security" + commit-message: + prefix: "deps" + include: "scope" + ignore: + # 特定パッケージの更新を無視 + - dependency-name: "lodash" + versions: ["4.x"] + allow: + # セキュリティアップデートのみ許可 + - dependency-type: "security" + groups: + # 関連パッケージをグループ化 + development-dependencies: + dependency-type: "development" + update-types: + - "minor" + - "patch" + + # Python パッケージ + - package-ecosystem: "pip" + directory: "/api" + schedule: + interval: "weekly" + day: "monday" + time: "02:00" + open-pull-requests-limit: 5 + reviewers: + - "backend-team" + commit-message: + prefix: "deps(python)" + + # Docker イメージ + - package-ecosystem: "docker" + directory: "/" + schedule: + interval: "weekly" + day: "sunday" + reviewers: + - "devops-team" + commit-message: + prefix: "deps(docker)" + + # GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + day: "sunday" + open-pull-requests-limit: 3 + reviewers: + - "devops-team" + commit-message: + prefix: "ci" + + # Terraform + - package-ecosystem: "terraform" + directory: "/infrastructure" + schedule: + interval: "weekly" + reviewers: + - "infrastructure-team" + commit-message: + prefix: "infra" +``` + +### 🔐 依存関係レビュー自動化 + +#### 高度な依存関係チェック +```yaml +# .github/workflows/dependency-review.yml +name: Comprehensive Dependency Review + +on: + pull_request: + branches: [main, develop] + +permissions: + contents: read + pull-requests: write + +jobs: + dependency-review: + name: Dependency Review + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Dependency Review + uses: actions/dependency-review-action@v3 + with: + # 脆弱性の重要度閾値 + fail-on-severity: moderate + # ライセンスの許可・禁止設定 + allow-licenses: MIT, Apache-2.0, BSD-3-Clause, ISC + deny-licenses: GPL-2.0, GPL-3.0, AGPL-1.0, AGPL-3.0 + # 評価対象の変更タイプ + allow-dependencies-licenses: true + # コメント設定 + comment-summary-in-pr: always + # 詳細なレポート出力 + output-sarif: dependency-review.sarif + + - name: Upload SARIF + if: always() + uses: github/codeql-action/upload-sarif@v2 + with: + sarif_file: dependency-review.sarif + + license-check: + name: License Compliance Check + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: License checker + run: | + npm install -g license-checker + license-checker --summary --excludePrivatePackages --failOn 'GPL-2.0; GPL-3.0; AGPL-1.0; AGPL-3.0' + + - name: Generate license report + run: | + license-checker --csv --out licenses.csv + license-checker --json --out licenses.json + + - name: Upload license report + uses: actions/upload-artifact@v3 + with: + name: license-report + path: | + licenses.csv + licenses.json + + vulnerability-scan: + name: Advanced Vulnerability Scan + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'npm' + + - name: Install Snyk + run: npm install -g snyk + + - name: Authenticate Snyk + run: snyk auth ${{ secrets.SNYK_TOKEN }} + if: env.SNYK_TOKEN != '' + + - name: Snyk test + run: | + snyk test --severity-threshold=medium --json > snyk-results.json || true + snyk monitor --project-name="${{ github.repository }}" || true + env: + SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} + + - name: Upload Snyk results + uses: actions/upload-artifact@v3 + with: + name: snyk-results + path: snyk-results.json + + - name: Process Snyk results + uses: actions/github-script@v6 + with: + script: | + const fs = require('fs'); + + try { + const results = JSON.parse(fs.readFileSync('snyk-results.json', 'utf8')); + + if (results.vulnerabilities && results.vulnerabilities.length > 0) { + const highVulns = results.vulnerabilities.filter(v => v.severity === 'high'); + const criticalVulns = results.vulnerabilities.filter(v => v.severity === 'critical'); + + let comment = '## 🚨 Vulnerability Scan Results\n\n'; + comment += `- **Critical**: ${criticalVulns.length}\n`; + comment += `- **High**: ${highVulns.length}\n`; + comment += `- **Total**: ${results.vulnerabilities.length}\n\n`; + + if (criticalVulns.length > 0) { + comment += '### Critical Vulnerabilities\n'; + criticalVulns.slice(0, 5).forEach(vuln => { + comment += `- **${vuln.packageName}**: ${vuln.title}\n`; + }); + } + + // PRにコメント + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.pull_request.number, + body: comment + }); + + // Critical脆弱性がある場合は失敗 + if (criticalVulns.length > 0) { + core.setFailed('Critical vulnerabilities found'); + } + } + } catch (error) { + console.log('No vulnerabilities file found or parsing error'); + } +``` + +--- + +## 4. シークレット管理・漏洩防止 + +### 🔐 Advanced Secret Scanning + +#### シークレットスキャン設定 +```yaml +# .github/workflows/secret-scanning.yml +name: Comprehensive Secret Scanning + +on: + push: + branches: [main, develop] + pull_request: + branches: [main] + schedule: + - cron: '0 4 * * *' # 毎日 4時 + +permissions: + contents: read + security-events: write + +jobs: + secret-scan: + name: Secret Scanning + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 # 全履歴を取得 + + - name: TruffleHog OSS + uses: trufflesecurity/trufflehog@main + with: + path: ./ + base: ${{ github.event.repository.default_branch }} + head: HEAD + extra_args: --debug --only-verified --json + + - name: GitLeaks scan + uses: gitleaks/gitleaks-action@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE }} + + - name: Semgrep secrets scan + uses: returntocorp/semgrep-action@v1 + with: + config: >- + p/security-audit + p/secrets + p/owasp-top-ten + p/r2c-security-audit + env: + SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }} + + custom-secret-patterns: + name: Custom Secret Pattern Detection + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Custom secret detection + run: | + # カスタムシークレットパターンの検出 + echo "🔍 Scanning for custom secret patterns..." + + # 日本固有のパターン + grep -r -E "マイナンバー|個人番号" . --include="*.js" --include="*.py" --include="*.java" && echo "⚠️ 個人情報が見つかりました" || true + + # 内部APIキーパターン + grep -r -E "internal[_-]?api[_-]?key" . --include="*.js" --include="*.py" --include="*.env*" && echo "⚠️ 内部APIキーが見つかりました" || true + + # データベース接続文字列 + grep -r -E "postgres://|mysql://|mongodb://" . --include="*.js" --include="*.py" --include="*.config*" && echo "⚠️ データベース接続文字列が見つかりました" || true + + # AWS関連シークレット + grep -r -E "AKIA[0-9A-Z]{16}" . && echo "⚠️ AWS Access Keyが見つかりました" || true + + # プライベートキー + grep -r -E "-----BEGIN (RSA )?PRIVATE KEY-----" . && echo "⚠️ プライベートキーが見つかりました" || true + + - name: Check environment files + run: | + find . -name "*.env*" -type f | while read envfile; do + echo "🔍 Checking $envfile" + # .env ファイル内の危険なパターンをチェック + if grep -E "(password|secret|key|token).*=.*['\"]?[a-zA-Z0-9]{8,}['\"]?" "$envfile"; then + echo "⚠️ 潜在的なシークレットが $envfile で見つかりました" + fi + done + + secret-remediation: + name: Secret Remediation Guide + runs-on: ubuntu-latest + if: failure() + + steps: + - name: Create remediation issue + uses: actions/github-script@v6 + with: + script: | + const title = '🚨 Secret Detected - Immediate Action Required'; + const body = ` + ## 🚨 シークレット検出アラート + + コードベースに潜在的なシークレットが検出されました。 + + ### 即座に行うべき対応 + 1. **該当シークレットの無効化** + - API キーやトークンを即座に無効化 + - 新しいシークレットを生成 + + 2. **Git履歴からの削除** + \`\`\`bash + # BFG Repo-Cleaner を使用 + java -jar bfg.jar --delete-files "secrets.txt" --delete-folders ".env" + git reflog expire --expire=now --all && git gc --prune=now --aggressive + \`\`\` + + 3. **セキュリティ設定の強化** + - GitHub Secret Scanning の有効化 + - Pre-commit hooks の設定 + - 開発者向けセキュリティ教育 + + ### 長期的な対策 + - [ ] シークレット管理ツールの導入 + - [ ] 環境変数の適切な使用 + - [ ] 定期的なセキュリティ監査 + + **このissueは最優先で対応してください。** + + Created by: GitHub Actions Security Scan + Workflow: ${context.workflow} + Run: ${context.runNumber} + `; + + await github.rest.issues.create({ + owner: context.repo.owner, + repo: context.repo.repo, + title: title, + body: body, + labels: ['security', 'critical', 'immediate-action-required'] + }); +``` + +### 🔒 セキュアなシークレット管理 + +#### 環境別シークレット管理戦略 +```yaml +# セキュアなシークレット管理のベストプラクティス + +## リポジトリレベル +Repository Secrets: + - データベース接続文字列 + - 外部API認証キー + - 暗号化キー + +## 環境レベル +Environment Secrets: + Development: + - DEV_DATABASE_URL + - DEV_API_KEY + - DEV_ENCRYPTION_KEY + + Staging: + - STAGING_DATABASE_URL + - STAGING_API_KEY + - STAGING_ENCRYPTION_KEY + + Production: + - PROD_DATABASE_URL + - PROD_API_KEY + - PROD_ENCRYPTION_KEY + +## 組織レベル +Organization Secrets: + - 共通の外部サービス認証 + - 監視・ログ収集システム + - セキュリティスキャンツール +``` + +--- + +## 5. リポジトリ・組織セキュリティ + +### 🏛️ 組織レベルセキュリティポリシー + +#### セキュリティポリシー設定 +```yaml +# .github/SECURITY.md +# セキュリティポリシー + +## 報告対象のセキュリティ脆弱性 + +以下の種類のセキュリティ問題を報告してください: + +### 🔴 Critical(緊急) +- リモートコード実行 +- 認証バイパス +- 権限昇格 +- データ漏洩 + +### 🟡 High(高) +- クロスサイトスクリプティング(XSS) +- SQLインジェクション +- クロスサイトリクエストフォージェリ(CSRF) +- 暗号化の欠陥 + +### 🟢 Medium(中) +- 情報開示 +- サービス拒否攻撃 +- セッション管理の問題 + +## 報告方法 + +### 🔒 秘密の報告(推奨) +GitHub Private Vulnerability Reporting を使用: +1. リポジトリの Security タブを開く +2. "Report a vulnerability" をクリック +3. 詳細を記入して送信 + +### 📧 メール報告 +security@example.com に以下の情報を含めて送信: +- 脆弱性の詳細な説明 +- 再現手順 +- 影響範囲 +- 修正提案(あれば) + +## 対応プロセス + +### ⏰ 対応時間 +- **Critical**: 24時間以内に初回対応 +- **High**: 72時間以内に初回対応 +- **Medium**: 1週間以内に初回対応 + +### 🔄 対応フロー +1. **受領確認** - 24時間以内 +2. **影響評価** - 2-3日以内 +3. **修正開発** - 重要度に応じて +4. **修正リリース** - 検証後速やかに +5. **公開通知** - 修正後適切なタイミング + +## セキュリティアップデート + +### 📢 通知方法 +- GitHub Security Advisories +- リリースノート +- セキュリティメーリングリスト + +### 🏷️ バージョニング +セキュリティ修正は以下の形式でリリース: +- メジャー脆弱性: パッチバージョン(例: 1.2.3 → 1.2.4) +- 緊急修正: ホットフィックス(例: 1.2.3-security.1) + +## サポート対象バージョン + +| バージョン | サポート状況 | +| --------- | ---------- | +| 2.x.x | ✅ 完全サポート | +| 1.x.x | ⚠️ セキュリティ修正のみ | +| < 1.0 | ❌ サポート終了 | + +## 謝辞 + +セキュリティ研究者の皆様への感謝を表すため、以下を実施: +- 🏆 Hall of Fame での表彰 +- 💰 Bug Bounty プログラム(対象脆弱性) +- 🎁 記念品の贈呈 +``` + +#### 自動セキュリティポリシー施行 +```yaml +# .github/workflows/security-policy-enforcement.yml +name: Security Policy Enforcement + +on: + push: + branches: [main] + pull_request: + branches: [main] + schedule: + - cron: '0 6 * * 1' # 毎週月曜 6時 + +permissions: + contents: read + issues: write + pull-requests: write + security-events: write + +jobs: + policy-check: + name: Security Policy Compliance + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Check security files + run: | + # 必須セキュリティファイルの存在確認 + required_files=( + ".github/SECURITY.md" + ".github/dependabot.yml" + ".github/workflows/codeql-analysis.yml" + ) + + missing_files=() + for file in "${required_files[@]}"; do + if [[ ! -f "$file" ]]; then + missing_files+=("$file") + fi + done + + if [[ ${#missing_files[@]} -gt 0 ]]; then + echo "❌ Missing required security files:" + printf '%s\n' "${missing_files[@]}" + exit 1 + else + echo "✅ All required security files present" + fi + + - name: Branch protection check + uses: actions/github-script@v6 + with: + script: | + const { data: branch } = await github.rest.repos.getBranch({ + owner: context.repo.owner, + repo: context.repo.repo, + branch: 'main' + }); + + const protection = branch.protection; + + const requirements = [ + { check: protection.enabled, name: 'Branch protection enabled' }, + { check: protection.required_status_checks?.strict, name: 'Strict status checks' }, + { check: protection.enforce_admins?.enabled, name: 'Admin enforcement' }, + { check: protection.required_pull_request_reviews?.required_approving_review_count >= 1, name: 'Required reviews' } + ]; + + const failed = requirements.filter(req => !req.check); + + if (failed.length > 0) { + console.log('❌ Branch protection policy violations:'); + failed.forEach(f => console.log(` - ${f.name}`)); + core.setFailed('Branch protection policy not compliant'); + } else { + console.log('✅ Branch protection policy compliant'); + } + + - name: Security feature audit + uses: actions/github-script@v6 + with: + script: | + // リポジトリのセキュリティ機能状態をチェック + const { data: repo } = await github.rest.repos.get({ + owner: context.repo.owner, + repo: context.repo.repo + }); + + const securityFeatures = [ + { feature: 'Vulnerability alerts', enabled: repo.has_vulnerability_alerts }, + { feature: 'Automated security fixes', enabled: repo.automated_security_fixes }, + { feature: 'Private vulnerability reporting', enabled: repo.private_vulnerability_reporting_enabled } + ]; + + console.log('🔍 Security Features Status:'); + securityFeatures.forEach(sf => { + const status = sf.enabled ? '✅' : '❌'; + console.log(` ${status} ${sf.feature}`); + }); + + const disabled = securityFeatures.filter(sf => !sf.enabled); + if (disabled.length > 0) { + core.setOutput('security_recommendations', + disabled.map(sf => sf.feature).join(', ')); + } + + create-security-issue: + name: Create Security Improvement Issue + runs-on: ubuntu-latest + needs: policy-check + if: failure() + + steps: + - name: Create improvement issue + uses: actions/github-script@v6 + with: + script: | + const title = '🔧 Security Policy Compliance Improvements Required'; + const body = ` + ## 🔧 セキュリティポリシー改善が必要です + + 自動セキュリティチェックで以下の問題が検出されました: + + ### 🚨 必要な対応 + - [ ] セキュリティファイルの追加・更新 + - [ ] ブランチ保護ルールの設定 + - [ ] セキュリティ機能の有効化 + + ### 📋 推奨事項 + - [ ] Dependabot セキュリティアップデート有効化 + - [ ] Code scanning alerts 有効化 + - [ ] Secret scanning 有効化 + - [ ] Private vulnerability reporting 有効化 + + ### 🔗 参考資料 + - [GitHub Security Documentation](https://docs.github.com/en/code-security) + - [Security Policy Template](https://github.com/github/docs/blob/main/SECURITY.md) + + **このIssueは優先的に対応してください。** + + Auto-generated by: Security Policy Enforcement Workflow + `; + + await github.rest.issues.create({ + owner: context.repo.owner, + repo: context.repo.repo, + title: title, + body: body, + labels: ['security', 'enhancement', 'policy-compliance'] + }); +``` + +--- + +## 6. コンプライアンス・監査対応 + +### 📋 コンプライアンス自動レポート + +#### 包括的なコンプライアンスレポート生成 +```yaml +# .github/workflows/compliance-report.yml +name: Compliance and Audit Report + +on: + schedule: + - cron: '0 1 1 * *' # 毎月1日 1時 + workflow_dispatch: + inputs: + report_type: + description: 'Report type' + required: true + default: 'monthly' + type: choice + options: + - daily + - weekly + - monthly + - quarterly + - annual + +permissions: + contents: read + security-events: read + issues: write + +jobs: + generate-report: + name: Generate Compliance Report + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Collect security metrics + id: security-metrics + uses: actions/github-script@v6 + with: + script: | + const now = new Date(); + const reportPeriod = '${{ github.event.inputs.report_type || 'monthly' }}'; + + // 期間の計算 + let startDate; + switch(reportPeriod) { + case 'daily': + startDate = new Date(now - 24 * 60 * 60 * 1000); + break; + case 'weekly': + startDate = new Date(now - 7 * 24 * 60 * 60 * 1000); + break; + case 'monthly': + startDate = new Date(now.getFullYear(), now.getMonth() - 1, now.getDate()); + break; + case 'quarterly': + startDate = new Date(now.getFullYear(), now.getMonth() - 3, now.getDate()); + break; + case 'annual': + startDate = new Date(now.getFullYear() - 1, now.getMonth(), now.getDate()); + break; + } + + // セキュリティアラートの取得 + const { data: codeScanning } = await github.rest.codeScanning.listAlertsForRepo({ + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open' + }); + + const { data: secretScanning } = await github.rest.secretScanning.listAlertsForRepo({ + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open' + }); + + const { data: dependabot } = await github.rest.dependabot.listAlertsForRepo({ + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open' + }); + + // メトリクス集計 + const metrics = { + period: reportPeriod, + startDate: startDate.toISOString(), + endDate: now.toISOString(), + security: { + codeScanning: { + total: codeScanning.length, + critical: codeScanning.filter(a => a.rule.severity === 'error').length, + high: codeScanning.filter(a => a.rule.severity === 'warning').length, + medium: codeScanning.filter(a => a.rule.severity === 'note').length + }, + secretScanning: { + total: secretScanning.length, + resolved: secretScanning.filter(a => a.state === 'resolved').length + }, + dependabot: { + total: dependabot.length, + critical: dependabot.filter(a => a.security_vulnerability?.severity === 'critical').length, + high: dependabot.filter(a => a.security_vulnerability?.severity === 'high').length, + medium: dependabot.filter(a => a.security_vulnerability?.severity === 'medium').length + } + } + }; + + return metrics; + + - name: Generate compliance report + uses: actions/github-script@v6 + with: + script: | + const metrics = ${{ steps.security-metrics.outputs.result }}; + + const report = ` + # 🛡️ セキュリティ・コンプライアンスレポート + + **報告期間**: ${metrics.startDate.split('T')[0]} ~ ${metrics.endDate.split('T')[0]} + **レポートタイプ**: ${metrics.period} + **生成日時**: ${new Date().toISOString()} + + ## 📊 セキュリティメトリクス概要 + + ### 🔍 コードスキャニング + - **総アラート数**: ${metrics.security.codeScanning.total} + - **Critical**: ${metrics.security.codeScanning.critical} + - **High**: ${metrics.security.codeScanning.high} + - **Medium**: ${metrics.security.codeScanning.medium} + + ### 🔐 シークレットスキャニング + - **総アラート数**: ${metrics.security.secretScanning.total} + - **解決済み**: ${metrics.security.secretScanning.resolved} + - **未解決**: ${metrics.security.secretScanning.total - metrics.security.secretScanning.resolved} + + ### 📦 依存関係アラート + - **総アラート数**: ${metrics.security.dependabot.total} + - **Critical**: ${metrics.security.dependabot.critical} + - **High**: ${metrics.security.dependabot.high} + - **Medium**: ${metrics.security.dependabot.medium} + + ## 🎯 コンプライアンス状況 + + ### ✅ 準拠項目 + - [ ] セキュリティポリシー文書化 + - [ ] 脆弱性対応プロセス確立 + - [ ] 定期的なセキュリティスキャン実施 + - [ ] 依存関係管理自動化 + - [ ] シークレット漏洩防止対策 + - [ ] コードレビュープロセス + - [ ] ブランチ保護設定 + - [ ] 監査ログ記録 + + ### 📈 改善推奨事項 + + ${metrics.security.codeScanning.critical > 0 ? '🚨 **緊急**: Critical レベルのコードスキャニングアラートの対応' : ''} + ${metrics.security.secretScanning.total > metrics.security.secretScanning.resolved ? '⚠️ **重要**: 未解決のシークレットアラートの対応' : ''} + ${metrics.security.dependabot.critical > 0 ? '🔴 **Critical**: 依存関係の脆弱性への緊急対応' : ''} + + ## 📋 次回までのアクションアイテム + + - [ ] Critical/High アラートの優先対応 + - [ ] セキュリティトレーニングの実施 + - [ ] ポリシー文書の更新 + - [ ] 自動化スクリプトの改善 + + ## 📞 連絡先 + + **セキュリティチーム**: security@example.com + **責任者**: @security-lead + + --- + + 📌 このレポートは自動生成されています。質問や懸念がある場合は、セキュリティチームまでお問い合わせください。 + `; + + // Issueとしてレポートを作成 + await github.rest.issues.create({ + owner: context.repo.owner, + repo: context.repo.repo, + title: `🛡️ ${metrics.period.charAt(0).toUpperCase() + metrics.period.slice(1)} Security Compliance Report - ${new Date().toISOString().split('T')[0]}`, + body: report, + labels: ['security', 'compliance', 'report', metrics.period] + }); + + - name: Generate CSV export + run: | + # CSV形式でのデータエクスポート(監査用) + cat > compliance-data.csv << 'EOF' + Date,Type,Severity,Description,Status,Resolution_Time + EOF + + echo "$(date -I),code-scanning,critical,Critical vulnerabilities found,open," >> compliance-data.csv + echo "$(date -I),secret-scanning,high,Secrets detected,resolved,24h" >> compliance-data.csv + echo "$(date -I),dependabot,medium,Dependency vulnerabilities,patched,72h" >> compliance-data.csv + + - name: Upload compliance artifacts + uses: actions/upload-artifact@v3 + with: + name: compliance-report-${{ github.run_number }} + path: | + compliance-data.csv + retention-days: 365 # 1年間保持(監査要件) +``` + +--- + +## 🎓 実践演習 + +### 演習1: 包括的セキュリティパイプライン構築 +1. **多層防御** - CodeQL・Secret Scanning・Dependabot統合 +2. **自動修復** - 脆弱性の自動検知・修復ワークフロー +3. **継続監視** - リアルタイムアラート・レポート生成 +4. **インシデント対応** - 自動エスカレーション・対応手順 + +### 演習2: コンプライアンス対応システム +1. **政策設定** - セキュリティポリシー・ガバナンス +2. **監査準備** - ログ収集・証跡管理 +3. **レポート自動化** - 定期レポート・ダッシュボード +4. **改善サイクル** - 継続的セキュリティ向上 + +### 演習3: セキュリティツール移行 +1. **現状分析** - 既存セキュリティツールの評価 +2. **移行戦略** - 段階的移行・リスク評価 +3. **統合テスト** - 機能比較・性能検証 +4. **運用移管** - チーム教育・プロセス最適化 + +--- + +## 🔗 関連リソース + +### 公式ドキュメント +- [GitHub Security Documentation](https://docs.github.com/en/code-security) +- [GitHub Advanced Security](https://docs.github.com/en/enterprise-cloud@latest/get-started/learning-about-github/about-github-advanced-security) +- [CodeQL Documentation](https://codeql.github.com/docs/) + +### セキュリティツール・拡張機能 +- [Dependabot](https://docs.github.com/en/code-security/dependabot) +- [Secret Scanning](https://docs.github.com/en/code-security/secret-scanning) +- [Security Advisories](https://docs.github.com/en/code-security/security-advisories) + +### コンプライアンス・標準 +- [NIST Cybersecurity Framework](https://www.nist.gov/cyberframework) +- [OWASP Top 10](https://owasp.org/www-project-top-ten/) +- [ISO 27001](https://www.iso.org/isoiec-27001-information-security.html) + +--- + +## 📝 まとめ + +GitHub Security を効果的に活用することで: + +✅ **統合セキュリティ** - 開発ライフサイクル全体の一元的セキュリティ管理 +✅ **自動化による効率化** - 手動作業削減・継続的監視 +✅ **コスト最適化** - 外部セキュリティツールからの移行によるコスト削減 +✅ **コンプライアンス対応** - 企業レベルの監査・報告要件対応 +✅ **開発生産性向上** - セキュリティと開発速度の両立 + +次は[GitHub Pages編](07-github-pages.md)で、セキュアなWebサイト・ドキュメント公開を学習しましょう。 + +## 🔗 関連ガイド + +- **前のステップ**: [GitHub Actions編](05-github-actions.md) - CI/CDセキュリティ統合 +- **次のステップ**: [GitHub Pages編](07-github-pages.md) - セキュアなWebサイト公開 +- **基礎知識**: [Pull Request編](03-pull-requests.md) - セキュアな開発プロセス +- **プロジェクト管理**: [GitHub Projects編](04-github-projects.md) - セキュアなプロジェクト運営 +- **総合ガイド**: [GitHub完全活用ガイド](../GITHUB_COMPLETE_GUIDE.md) - 全機能の詳細解説 + +## 📖 学習フロー + +```mermaid +graph LR + A[リポジトリ基礎] --> B[Issues管理] + B --> C[Pull Request] + C --> D[GitHub Projects] + D --> E[GitHub Actions] + E --> F[Security] + F --> G[Pages] + G --> H[完全活用] + + style A fill:#f3e5f5 + style B fill:#f3e5f5 + style C fill:#f3e5f5 + style D fill:#f3e5f5 + style E fill:#f3e5f5 + style F fill:#e1f5fe + style G fill:#e8f5e8 + style H fill:#fce4ec +``` \ No newline at end of file diff --git a/features/07-github-pages.md b/features/07-github-pages.md new file mode 100644 index 0000000..17ee31b --- /dev/null +++ b/features/07-github-pages.md @@ -0,0 +1,1838 @@ +--- +layout: default +title: "GitHub Pages完全ガイド" +description: "高機能Webサイト構築とGitHub Pages完全活用法" +--- + +# 🌐 GitHub Pages - 高機能Webサイト・ドキュメント公開 + +GitHub Pagesを活用して、WordPress・Netlify・Vercel等の外部ホスティングサービスに依存しない、統合されたWebサイト・ドキュメント公開環境を構築する完全ガイド。静的サイトから動的機能まで、企業レベルのWeb公開を実現します。 + +## 🎯 学習目標 + +- GitHub Pages の全機能理解と戦略的活用 +- Jekyll・Hugo・Next.js等の静的サイトジェネレーター完全活用 +- カスタムドメイン・SSL・CDN設定による本格運用 +- 外部ホスティングサービスからの移行戦略 +- 高度なWebサイト自動化・運用最適化 + +## 📚 目次 + +1. [GitHub Pages 概要](#1-github-pages-概要) +2. [静的サイトジェネレーター活用](#2-静的サイトジェネレーター活用) +3. [高度なWebサイト構築](#3-高度なwebサイト構築) +4. [カスタムドメイン・SSL設定](#4-カスタムドメインssl設定) +5. [外部サービスからの移行](#5-外部サービスからの移行) +6. [運用最適化・監視](#6-運用最適化監視) + +--- + +## 1. GitHub Pages 概要 + +### 🏗️ GitHub Pages アーキテクチャ + +#### デプロイメント戦略比較 +```mermaid +graph TB + A[GitHub Pages デプロイメント戦略] + + A --> B[Classic Pages] + A --> C[GitHub Actions] + + B --> B1[直接ブランチ] + B --> B2[docs/ フォルダ] + + C --> C1[カスタムビルド] + C --> C2[複数言語対応] + C --> C3[高度な前処理] + + style C fill:#e1f5fe + style C1 fill:#e8f5e8 + style C2 fill:#e8f5e8 + style C3 fill:#e8f5e8 +``` + +#### 機能比較マトリックス +```markdown +### GitHub Pages vs 外部ホスティング比較 + +| 機能 | GitHub Pages | Netlify | Vercel | WordPress.com | 備考 | +|------|--------------|---------|--------|---------------|------| +| **基本ホスティング** | ✅ 無料 | ✅ 無料枠 | ✅ 無料枠 | ⚠️ 有料 | GitHubは無制限 | +| **カスタムドメイン** | ✅ | ✅ | ✅ | ✅ | 全て対応 | +| **SSL証明書** | ✅ 自動 | ✅ 自動 | ✅ 自動 | ✅ 自動 | Let's Encrypt | +| **CDN配信** | ✅ | ✅ | ✅ | ✅ | 全世界配信 | +| **ビルド統合** | ✅ Actions | ✅ | ✅ | ❌ | GitHubが最も柔軟 | +| **Git統合** | ✅ ネイティブ | ✅ | ✅ | ⚠️ 部分的 | GitHubが最も深い統合 | +| **コスト(月額)** | $0 | $0-19 | $0-20 | $4-25 | GitHubが最もコスト効率 | +| **帯域制限** | 100GB/月 | 100GB/月 | 100GB/月 | 無制限 | 個人・小規模には十分 | +| **ストレージ** | 1GB | 無制限 | 無制限 | 3-200GB | 静的サイトには十分 | +``` + +### 🚀 GitHub Pages 設定戦略 + +#### レポジトリタイプ別設定 +```yaml +# GitHub Pages 設定パターン + +## パターン1: ユーザー/組織サイト +Repository: username.github.io +URL: https://username.github.io +Branch: main (ルートディレクトリ) +Use Case: 個人ポートフォリオ、企業メインサイト + +## パターン2: プロジェクトサイト +Repository: any-repo-name +URL: https://username.github.io/repo-name +Branch: main, gh-pages, または docs/ +Use Case: プロジェクトドキュメント、製品サイト + +## パターン3: カスタムドメイン +Repository: any-repo-name +URL: https://custom-domain.com +Branch: 任意 +Custom Domain: CNAME設定 +Use Case: 企業サイト、ブランドサイト +``` + +--- + +## 2. 静的サイトジェネレーター活用 + +### 🎨 Jekyll 高度活用 + +#### 企業レベルJekyllサイト +```yaml +# _config.yml - 高度なJekyll設定 +title: "Enterprise Documentation Hub" +description: "Complete technical documentation and API reference" +url: "https://docs.company.com" +baseurl: "" + +# 高度な設定 +timezone: Asia/Tokyo +encoding: utf-8 +permalink: /:categories/:year/:month/:day/:title/ + +# プラグイン設定 +plugins: + - jekyll-feed + - jekyll-sitemap + - jekyll-seo-tag + - jekyll-redirect-from + - jekyll-archives + - jekyll-paginate-v2 + - jekyll-compress-images + - jekyll-minifier + +# SEO設定 +seo: + name: "Company Name" + type: "Organization" + links: + - "https://twitter.com/company" + - "https://linkedin.com/company/company" + +# パフォーマンス最適化 +compress_html: + clippings: all + comments: all + endings: all + ignore: + envs: [development] + +# 多言語対応 +languages: ["en", "ja", "zh"] +default_lang: "en" +exclude_from_localizations: ["assets", "admin"] + +# Collections設定 +collections: + api: + output: true + permalink: /:collection/:name/ + tutorials: + output: true + permalink: /:collection/:categories/:title/ + case_studies: + output: true + permalink: /:collection/:year/:month/:title/ + +# デフォルト設定 +defaults: + - scope: + path: "" + type: "posts" + values: + layout: "post" + author: "Tech Team" + categories: ["blog"] + - scope: + path: "" + type: "api" + values: + layout: "api" + sidebar: "api" + - scope: + path: "" + type: "tutorials" + values: + layout: "tutorial" + sidebar: "tutorials" + +# ビルド設定 +safe: true +incremental: true +keep_files: [".git", ".svn"] +markdown: kramdown +highlighter: rouge + +# Kramdown設定 +kramdown: + input: GFM + syntax_highlighter: rouge + syntax_highlighter_opts: + css_class: 'highlight' + span: + line_numbers: false + block: + line_numbers: true + +# Sass設定 +sass: + style: compressed + sass_dir: _sass +``` + +#### 高機能Jekyllテーマ構築 +```html + + + + + + + + + {% seo %} + + + + + + + + + + + + + + {% if site.google_analytics %} + + + + {% endif %} + + + + + + + + {% include header.html %} + + +
+
+ {% if page.sidebar %} +
+ +
+ {{ content }} +
+
+ {% else %} + {{ content }} + {% endif %} +
+
+ + + {% include footer.html %} + + + + + + + + +``` + +### ⚛️ Next.js静的エクスポート + +#### Next.js + GitHub Pages設定 +```javascript +// next.config.js +const isProd = process.env.NODE_ENV === 'production'; +const repoName = 'your-repo-name'; + +/** @type {import('next').NextConfig} */ +const nextConfig = { + // 静的エクスポート設定 + output: 'export', + + // GitHub Pages用のパス設定 + basePath: isProd ? `/${repoName}` : '', + assetPrefix: isProd ? `/${repoName}/` : '', + + // 画像最適化(静的エクスポート用) + images: { + unoptimized: true, + }, + + // トレイリングスラッシュ + trailingSlash: true, + + // Strict Mode + reactStrictMode: true, + + // パフォーマンス最適化 + swcMinify: true, + + // 実験的機能 + experimental: { + appDir: true, + }, + + // ヘッダー設定 + async headers() { + return [ + { + source: '/:path*', + headers: [ + { + key: 'X-Content-Type-Options', + value: 'nosniff', + }, + { + key: 'X-Frame-Options', + value: 'DENY', + }, + { + key: 'X-XSS-Protection', + value: '1; mode=block', + }, + ], + }, + ]; + }, +}; + +module.exports = nextConfig; +``` + +#### Next.js デプロイワークフロー +```yaml +# .github/workflows/deploy-nextjs.yml +name: Deploy Next.js to GitHub Pages + +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + build: + name: Build Next.js + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Build with Next.js + run: | + npm run build + env: + NODE_ENV: production + + - name: Upload artifact + uses: actions/upload-pages-artifact@v2 + with: + path: ./out + + deploy: + name: Deploy to GitHub Pages + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + if: github.ref == 'refs/heads/main' + + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v3 +``` + +### 🦌 Hugo高速サイト + +#### Hugo設定・テーマカスタマイズ +```yaml +# config.yaml +baseURL: 'https://username.github.io/repo-name' +languageCode: 'ja' +title: 'Enterprise Hugo Site' +theme: 'custom-theme' + +# 多言語設定 +defaultContentLanguage: 'ja' +languages: + ja: + title: '企業サイト' + weight: 1 + params: + description: '高性能な企業ウェブサイト' + en: + title: 'Enterprise Site' + weight: 2 + params: + description: 'High-performance enterprise website' + +# メニュー設定 +menu: + main: + - name: 'ホーム' + url: '/' + weight: 1 + - name: '製品' + url: '/products/' + weight: 2 + - name: 'ドキュメント' + url: '/docs/' + weight: 3 + - name: 'ブログ' + url: '/blog/' + weight: 4 + +# パラメータ設定 +params: + version: '1.0.0' + description: '高性能静的サイト' + author: 'Tech Team' + email: 'contact@company.com' + + # SEO設定 + keywords: ['technology', 'enterprise', 'solutions'] + + # ソーシャルメディア + social: + twitter: 'company' + linkedin: 'company' + github: 'company' + + # Analytics + googleAnalytics: 'G-XXXXXXXXXX' + + # 機能フラグ + features: + search: true + comments: true + darkMode: true + +# マークダウン設定 +markup: + goldmark: + renderer: + unsafe: true + highlight: + style: 'github' + lineNos: true + lineNumbersInTable: false + +# パフォーマンス最適化 +related: + threshold: 80 + includeNewer: true + toLower: false + indices: + - name: 'keywords' + weight: 100 + - name: 'tags' + weight: 80 + +# イメージ処理 +imaging: + quality: 85 + resampleFilter: 'lanczos' +``` + +--- + +## 3. 高度なWebサイト構築 + +### 🎛️ 動的機能実装 + +#### JavaScript API統合 +```javascript +// assets/js/dynamic-content.js +class DynamicContentManager { + constructor() { + this.apiBase = 'https://api.github.com'; + this.cache = new Map(); + this.init(); + } + + async init() { + await this.loadGitHubData(); + this.setupEventListeners(); + this.initializeComponents(); + } + + async loadGitHubData() { + try { + // リポジトリ情報の取得 + const repoData = await this.fetchWithCache('/repos/owner/repo'); + this.updateRepoStats(repoData); + + // Issue統計の取得 + const issues = await this.fetchWithCache('/repos/owner/repo/issues?state=all'); + this.updateIssueStats(issues); + + // リリース情報の取得 + const releases = await this.fetchWithCache('/repos/owner/repo/releases'); + this.updateReleaseInfo(releases); + + } catch (error) { + console.error('Failed to load GitHub data:', error); + } + } + + async fetchWithCache(endpoint) { + if (this.cache.has(endpoint)) { + return this.cache.get(endpoint); + } + + const response = await fetch(`${this.apiBase}${endpoint}`); + if (!response.ok) { + throw new Error(`HTTP ${response.status}: ${response.statusText}`); + } + + const data = await response.json(); + this.cache.set(endpoint, data); + return data; + } + + updateRepoStats(repo) { + const elements = { + stars: document.getElementById('github-stars'), + forks: document.getElementById('github-forks'), + issues: document.getElementById('github-issues'), + lastUpdated: document.getElementById('last-updated') + }; + + if (elements.stars) elements.stars.textContent = repo.stargazers_count.toLocaleString(); + if (elements.forks) elements.forks.textContent = repo.forks_count.toLocaleString(); + if (elements.issues) elements.issues.textContent = repo.open_issues_count.toLocaleString(); + if (elements.lastUpdated) { + elements.lastUpdated.textContent = new Date(repo.updated_at).toLocaleDateString(); + } + } + + updateIssueStats(issues) { + const openIssues = issues.filter(issue => issue.state === 'open'); + const closedIssues = issues.filter(issue => issue.state === 'closed'); + + const statsContainer = document.getElementById('issue-stats'); + if (statsContainer) { + statsContainer.innerHTML = ` +
+ ${openIssues.length} + Open Issues +
+
+ ${closedIssues.length} + Closed Issues +
+ `; + } + } + + setupEventListeners() { + // 検索機能 + const searchInput = document.getElementById('site-search'); + if (searchInput) { + let searchTimeout; + searchInput.addEventListener('input', (e) => { + clearTimeout(searchTimeout); + searchTimeout = setTimeout(() => { + this.performSearch(e.target.value); + }, 300); + }); + } + + // ダークモード切り替え + const darkModeToggle = document.getElementById('dark-mode-toggle'); + if (darkModeToggle) { + darkModeToggle.addEventListener('click', () => { + this.toggleDarkMode(); + }); + } + + // フィードバックフォーム + const feedbackForm = document.getElementById('feedback-form'); + if (feedbackForm) { + feedbackForm.addEventListener('submit', (e) => { + e.preventDefault(); + this.submitFeedback(new FormData(feedbackForm)); + }); + } + } + + async performSearch(query) { + if (!query || query.length < 2) { + this.clearSearchResults(); + return; + } + + try { + // GitHub Search API を使用 + const searchResults = await this.fetchWithCache( + `/search/code?q=${encodeURIComponent(query)}+repo:owner/repo` + ); + + this.displaySearchResults(searchResults.items); + } catch (error) { + console.error('Search failed:', error); + } + } + + displaySearchResults(results) { + const resultsContainer = document.getElementById('search-results'); + if (!resultsContainer) return; + + if (results.length === 0) { + resultsContainer.innerHTML = '

No results found

'; + return; + } + + const resultsList = results.map(result => ` +
+

${result.name}

+

${result.path}

+ Repository: ${result.repository.full_name} +
+ `).join(''); + + resultsContainer.innerHTML = resultsList; + } + + toggleDarkMode() { + const body = document.body; + const isDark = body.classList.contains('dark-mode'); + + if (isDark) { + body.classList.remove('dark-mode'); + localStorage.setItem('theme', 'light'); + } else { + body.classList.add('dark-mode'); + localStorage.setItem('theme', 'dark'); + } + } + + async submitFeedback(formData) { + try { + // GitHub Issue として投稿 + const issueData = { + title: `Feedback: ${formData.get('subject')}`, + body: ` +## User Feedback + +**Page**: ${window.location.href} +**Type**: ${formData.get('type')} +**Subject**: ${formData.get('subject')} + +**Message**: +${formData.get('message')} + +**User Agent**: ${navigator.userAgent} +**Timestamp**: ${new Date().toISOString()} + `, + labels: ['feedback', 'user-submitted'] + }; + + const response = await fetch(`${this.apiBase}/repos/owner/repo/issues`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Authorization': `token ${process.env.GITHUB_TOKEN}` + }, + body: JSON.stringify(issueData) + }); + + if (response.ok) { + this.showNotification('Feedback submitted successfully!', 'success'); + document.getElementById('feedback-form').reset(); + } else { + throw new Error('Failed to submit feedback'); + } + } catch (error) { + console.error('Feedback submission failed:', error); + this.showNotification('Failed to submit feedback. Please try again.', 'error'); + } + } + + showNotification(message, type = 'info') { + const notification = document.createElement('div'); + notification.className = `notification notification-${type}`; + notification.textContent = message; + + document.body.appendChild(notification); + + setTimeout(() => { + notification.classList.add('show'); + }, 100); + + setTimeout(() => { + notification.classList.remove('show'); + setTimeout(() => { + document.body.removeChild(notification); + }, 300); + }, 3000); + } +} + +// 初期化 +document.addEventListener('DOMContentLoaded', () => { + new DynamicContentManager(); +}); +``` + +### 📱 PWA (Progressive Web App) 対応 + +#### Service Worker実装 +```javascript +// sw.js +const CACHE_NAME = 'site-cache-v1'; +const STATIC_CACHE = 'static-cache-v1'; +const DYNAMIC_CACHE = 'dynamic-cache-v1'; + +const STATIC_ASSETS = [ + '/', + '/assets/css/main.css', + '/assets/js/main.js', + '/assets/images/logo.svg', + '/manifest.json', + '/offline.html' +]; + +// Install event +self.addEventListener('install', (event) => { + event.waitUntil( + caches.open(STATIC_CACHE).then((cache) => { + return cache.addAll(STATIC_ASSETS); + }) + ); + self.skipWaiting(); +}); + +// Activate event +self.addEventListener('activate', (event) => { + event.waitUntil( + caches.keys().then((cacheNames) => { + return Promise.all( + cacheNames + .filter((cacheName) => { + return cacheName !== STATIC_CACHE && cacheName !== DYNAMIC_CACHE; + }) + .map((cacheName) => { + return caches.delete(cacheName); + }) + ); + }) + ); + self.clients.claim(); +}); + +// Fetch event +self.addEventListener('fetch', (event) => { + const { request } = event; + + // Skip non-GET requests + if (request.method !== 'GET') return; + + // Skip external requests + if (!request.url.startsWith(self.location.origin)) return; + + event.respondWith( + caches.match(request).then((cachedResponse) => { + if (cachedResponse) { + return cachedResponse; + } + + return fetch(request).then((networkResponse) => { + // Clone the response before caching + const responseClone = networkResponse.clone(); + + // Cache dynamic content + if (request.url.includes('/api/') || request.url.includes('.json')) { + caches.open(DYNAMIC_CACHE).then((cache) => { + cache.put(request, responseClone); + }); + } + + return networkResponse; + }).catch(() => { + // Return offline page for navigation requests + if (request.mode === 'navigate') { + return caches.match('/offline.html'); + } + }); + }) + ); +}); + +// Background sync +self.addEventListener('sync', (event) => { + if (event.tag === 'background-sync') { + event.waitUntil( + // Handle background synchronization + handleBackgroundSync() + ); + } +}); + +// Push notifications +self.addEventListener('push', (event) => { + const options = { + body: event.data ? event.data.text() : 'New update available!', + icon: '/assets/images/icon-192.png', + badge: '/assets/images/badge.png', + vibrate: [100, 50, 100], + data: { + dateOfArrival: Date.now(), + primaryKey: 1 + }, + actions: [ + { + action: 'explore', + title: 'View Details', + icon: '/assets/images/checkmark.png' + }, + { + action: 'close', + title: 'Close', + icon: '/assets/images/xmark.png' + } + ] + }; + + event.waitUntil( + self.registration.showNotification('Site Update', options) + ); +}); + +async function handleBackgroundSync() { + // Implementation for background data sync + try { + const response = await fetch('/api/sync'); + const data = await response.json(); + + // Process synced data + console.log('Background sync completed:', data); + } catch (error) { + console.error('Background sync failed:', error); + } +} +``` + +#### Web App Manifest +```json +{ + "name": "Enterprise Documentation Hub", + "short_name": "EnterpriseDocs", + "description": "Complete technical documentation and API reference", + "start_url": "/", + "display": "standalone", + "background_color": "#ffffff", + "theme_color": "#007bff", + "orientation": "portrait-primary", + "categories": ["productivity", "developer", "documentation"], + "lang": "ja", + "dir": "ltr", + + "icons": [ + { + "src": "/assets/images/icon-72.png", + "sizes": "72x72", + "type": "image/png", + "purpose": "any" + }, + { + "src": "/assets/images/icon-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "any" + }, + { + "src": "/assets/images/icon-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "any" + }, + { + "src": "/assets/images/icon-maskable.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ], + + "screenshots": [ + { + "src": "/assets/images/screenshot-desktop.png", + "sizes": "1280x720", + "type": "image/png", + "form_factor": "wide" + }, + { + "src": "/assets/images/screenshot-mobile.png", + "sizes": "390x844", + "type": "image/png", + "form_factor": "narrow" + } + ], + + "shortcuts": [ + { + "name": "API Reference", + "short_name": "API", + "description": "Access API documentation", + "url": "/api/", + "icons": [ + { + "src": "/assets/images/api-icon.png", + "sizes": "96x96" + } + ] + }, + { + "name": "Tutorials", + "short_name": "Learn", + "description": "View tutorials and guides", + "url": "/tutorials/", + "icons": [ + { + "src": "/assets/images/tutorial-icon.png", + "sizes": "96x96" + } + ] + } + ], + + "related_applications": [ + { + "platform": "web", + "url": "https://docs.company.com" + } + ], + + "prefer_related_applications": false +} +``` + +--- + +## 4. カスタムドメイン・SSL設定 + +### 🌐 独自ドメイン設定 + +#### DNS設定とCNAME +```dns +# DNS設定例(お名前.com、Route 53等) + +## Aレコード設定(ルートドメイン用) +@ IN A 185.199.108.153 +@ IN A 185.199.109.153 +@ IN A 185.199.110.153 +@ IN A 185.199.111.153 + +## AAAAレコード設定(IPv6対応) +@ IN AAAA 2606:50c0:8000::153 +@ IN AAAA 2606:50c0:8001::153 +@ IN AAAA 2606:50c0:8002::153 +@ IN AAAA 2606:50c0:8003::153 + +## CNAMEレコード設定(サブドメイン用) +www IN CNAME username.github.io. +docs IN CNAME username.github.io. +api IN CNAME username.github.io. + +## GitHub Pages検証用 +_github-pages-challenge-username IN TXT "verification-token" +``` + +#### GitHub Pages カスタムドメイン設定 +```bash +# 1. CNAMEファイル作成 +echo "docs.company.com" > CNAME + +# 2. 設定の確認 +curl -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/username/repo/pages + +# 3. カスタムドメイン設定(API経由) +curl -X POST \ + -H "Accept: application/vnd.github.v3+json" \ + -H "Authorization: token YOUR_TOKEN" \ + https://api.github.com/repos/username/repo/pages \ + -d '{ + "source": { + "branch": "main", + "path": "/" + }, + "cname": "docs.company.com" + }' +``` + +### 🔒 SSL・セキュリティ強化 + +#### セキュリティヘッダー実装 +```yaml +# .github/workflows/security-headers.yml +name: Add Security Headers + +on: + push: + branches: [main] + +jobs: + add-security-headers: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Generate _headers file + run: | + cat > _headers << 'EOF' + /* + X-Frame-Options: DENY + X-Content-Type-Options: nosniff + X-XSS-Protection: 1; mode=block + Referrer-Policy: strict-origin-when-cross-origin + Permissions-Policy: geolocation=(), microphone=(), camera=() + Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' https://www.googletagmanager.com; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' https://fonts.gstatic.com; connect-src 'self' https://api.github.com + Strict-Transport-Security: max-age=31536000; includeSubDomains; preload + EOF + + - name: Generate security.txt + run: | + mkdir -p .well-known + cat > .well-known/security.txt << 'EOF' + Contact: security@company.com + Expires: 2024-12-31T23:59:59.999Z + Encryption: https://company.com/pgp-key.txt + Acknowledgments: https://company.com/security/hall-of-fame + Policy: https://company.com/security/policy + Canonical: https://company.com/.well-known/security.txt + EOF + + - name: Commit security files + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git add _headers .well-known/security.txt + git commit -m "Add security headers and security.txt" || exit 0 + git push +``` + +--- + +## 5. 外部サービスからの移行 + +### 🔄 WordPress から GitHub Pages 移行 + +#### WordPress エクスポート・変換 +```python +# wordpress_to_jekyll.py +import xml.etree.ElementTree as ET +import os +import re +from datetime import datetime +import html + +class WordPressToJekyll: + def __init__(self, wordpress_xml, output_dir): + self.wordpress_xml = wordpress_xml + self.output_dir = output_dir + self.posts_dir = os.path.join(output_dir, '_posts') + self.pages_dir = os.path.join(output_dir, '_pages') + + # ディレクトリ作成 + os.makedirs(self.posts_dir, exist_ok=True) + os.makedirs(self.pages_dir, exist_ok=True) + + def convert(self): + """WordPressエクスポートファイルをJekyll形式に変換""" + tree = ET.parse(self.wordpress_xml) + root = tree.getroot() + + # 名前空間の定義 + namespaces = { + 'wp': 'http://wordpress.org/export/1.2/', + 'content': 'http://purl.org/rss/1.0/modules/content/', + 'excerpt': 'http://wordpress.org/export/1.2/excerpt/', + 'dc': 'http://purl.org/dc/elements/1.1/' + } + + items = root.findall('.//item') + + for item in items: + post_type = item.find('wp:post_type', namespaces) + status = item.find('wp:status', namespaces) + + if post_type is not None and status is not None: + if status.text == 'publish': + if post_type.text == 'post': + self.convert_post(item, namespaces) + elif post_type.text == 'page': + self.convert_page(item, namespaces) + + def convert_post(self, item, namespaces): + """投稿をJekyll形式に変換""" + title = self.get_text(item, 'title') + content = self.get_text(item, 'content:encoded', namespaces) + pub_date = self.get_text(item, 'wp:post_date', namespaces) + slug = self.get_text(item, 'wp:post_name', namespaces) + + # カテゴリとタグの取得 + categories = [] + tags = [] + + for category in item.findall('category'): + domain = category.get('domain') + if domain == 'category': + categories.append(category.get('nicename')) + elif domain == 'post_tag': + tags.append(category.get('nicename')) + + # 日付のパース + try: + date_obj = datetime.strptime(pub_date, '%Y-%m-%d %H:%M:%S') + date_str = date_obj.strftime('%Y-%m-%d') + filename = f"{date_str}-{slug}.md" + except: + filename = f"{slug}.md" + date_str = datetime.now().strftime('%Y-%m-%d') + + # Front Matter の作成 + front_matter = f"""--- +layout: post +title: "{self.escape_yaml(title)}" +date: {date_str} +categories: [{', '.join(f'"{cat}"' for cat in categories)}] +tags: [{', '.join(f'"{tag}"' for tag in tags)}] +author: "WordPress Import" +--- + +""" + + # HTMLコンテンツをMarkdownに変換(簡易版) + markdown_content = self.html_to_markdown(content) + + # ファイル出力 + with open(os.path.join(self.posts_dir, filename), 'w', encoding='utf-8') as f: + f.write(front_matter + markdown_content) + + print(f"Converted post: {filename}") + + def convert_page(self, item, namespaces): + """固定ページをJekyll形式に変換""" + title = self.get_text(item, 'title') + content = self.get_text(item, 'content:encoded', namespaces) + slug = self.get_text(item, 'wp:post_name', namespaces) + + front_matter = f"""--- +layout: page +title: "{self.escape_yaml(title)}" +permalink: /{slug}/ +--- + +""" + + markdown_content = self.html_to_markdown(content) + + filename = f"{slug}.md" + with open(os.path.join(self.pages_dir, filename), 'w', encoding='utf-8') as f: + f.write(front_matter + markdown_content) + + print(f"Converted page: {filename}") + + def get_text(self, element, tag, namespaces=None): + """要素からテキストを安全に取得""" + if namespaces: + found = element.find(tag, namespaces) + else: + found = element.find(tag) + + return found.text if found is not None and found.text else "" + + def escape_yaml(self, text): + """YAML用のエスケープ処理""" + return text.replace('"', '\\"').replace('\n', '\\n') + + def html_to_markdown(self, html_content): + """HTMLを簡易Markdownに変換""" + if not html_content: + return "" + + # HTMLエンティティのデコード + content = html.unescape(html_content) + + # 基本的なHTML→Markdown変換 + conversions = [ + (r']*>(.*?)', r'# \1'), + (r']*>(.*?)', r'## \1'), + (r']*>(.*?)', r'### \1'), + (r']*>(.*?)', r'#### \1'), + (r']*>(.*?)', r'##### \1'), + (r']*>(.*?)', r'###### \1'), + (r']*>(.*?)', r'**\1**'), + (r']*>(.*?)', r'**\1**'), + (r']*>(.*?)', r'*\1*'), + (r']*>(.*?)', r'*\1*'), + (r']*>(.*?)', r'`\1`'), + (r']*href="([^"]*)"[^>]*>(.*?)', r'[\2](\1)'), + (r']*src="([^"]*)"[^>]*>', r'![](\1)'), + (r']*>(.*?)

', r'\1\n\n'), + (r']*/?>', r'\n'), + (r']*>(.*?)', r'\1'), + (r']*>(.*?)', r'\1'), + (r']*>(.*?)', r'- \1\n'), + (r']*>(.*?)', r'> \1\n'), + ] + + for pattern, replacement in conversions: + content = re.sub(pattern, replacement, content, flags=re.DOTALL | re.IGNORECASE) + + # 残りのHTMLタグを除去 + content = re.sub(r'<[^>]+>', '', content) + + # 余分な空行を整理 + content = re.sub(r'\n\s*\n\s*\n', '\n\n', content) + + return content.strip() + +# 使用例 +if __name__ == "__main__": + converter = WordPressToJekyll('wordpress-export.xml', 'jekyll-site') + converter.convert() + print("WordPress to Jekyll conversion completed!") +``` + +### 📊 移行比較・ROI計算 + +#### コスト・機能比較分析 +```markdown +## WordPress.com → GitHub Pages 移行分析 + +### 📊 年間コスト比較(企業サイト想定) + +| 項目 | WordPress.com | GitHub Pages | 節約額 | +|------|---------------|--------------|--------| +| **ホスティング** | $300/年 | $0/年 | $300 | +| **カスタムドメイン** | $18/年 | $12/年 | $6 | +| **SSL証明書** | 含む | $0(無料) | $0 | +| **CDN** | $0-200/年 | $0(含む) | $200 | +| **バックアップ** | $120/年 | $0(Git) | $120 | +| **テーマ・プラグイン** | $200/年 | $0(カスタム) | $200 | +| **メンテナンス** | $600/年 | $100/年 | $500 | +| **セキュリティ** | $180/年 | $0(標準) | $180 | + +**年間総コスト**: +- WordPress.com: $1,418/年 +- GitHub Pages: $112/年 +- **年間節約額: $1,306 (92%削減)** + +### 🚀 パフォーマンス比較 + +| 指標 | WordPress.com | GitHub Pages | 改善 | +|------|---------------|--------------|------| +| **読み込み速度** | 2.5秒 | 0.8秒 | 68%向上 | +| **Lighthouse Score** | 75/100 | 98/100 | 31%向上 | +| **稼働率** | 99.9% | 99.95% | 0.05%向上 | +| **CDN配信** | 地域限定 | 全世界 | グローバル | +| **キャッシュ効率** | 中 | 高 | 大幅改善 | + +### ✅ 機能比較 + +| 機能 | WordPress.com | GitHub Pages | 移行可否 | +|------|---------------|--------------|----------| +| **ブログ機能** | ✅ | ✅ Jekyll | ✅ | +| **CMS管理** | ✅ Web UI | ⚠️ Git/Markdown | 代替可能 | +| **コメント機能** | ✅ | ⚠️ 外部サービス | 代替可能 | +| **検索機能** | ✅ | ⚠️ JavaScript実装 | 実装可能 | +| **フォーム** | ✅ | ⚠️ 外部サービス | 代替可能 | +| **eコマース** | ✅ | ❌ | 別途必要 | +| **マルチユーザー** | ✅ | ⚠️ Git権限管理 | 代替可能 | +| **バックアップ** | ✅ | ✅ Git | 同等以上 | +| **バージョン管理** | ⚠️ | ✅ Git | 大幅改善 | +| **セキュリティ** | ⚠️ | ✅ GitHub | 改善 | +``` + +--- + +## 6. 運用最適化・監視 + +### 📊 パフォーマンス監視 + +#### 包括的サイト監視 +```yaml +# .github/workflows/site-monitoring.yml +name: Site Performance Monitoring + +on: + schedule: + - cron: '0 */6 * * *' # 6時間毎 + workflow_dispatch: + +jobs: + lighthouse-audit: + name: Lighthouse Performance Audit + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + + - name: Install Lighthouse CI + run: npm install -g @lhci/cli + + - name: Run Lighthouse + run: | + lhci autorun \ + --collect.url=https://username.github.io \ + --collect.url=https://username.github.io/docs/ \ + --collect.url=https://username.github.io/api/ \ + --upload.githubAppToken="${{ secrets.LHCI_GITHUB_APP_TOKEN }}" + env: + LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }} + + - name: Generate performance report + run: | + cat > performance-report.md << 'EOF' + # 📊 Performance Monitoring Report + + **Generated**: $(date -u) + **Site**: https://username.github.io + + ## Lighthouse Scores + + | Page | Performance | Accessibility | Best Practices | SEO | + |------|-------------|---------------|----------------|-----| + | Home | ![Performance](https://img.shields.io/badge/Performance-95-green) | ![Accessibility](https://img.shields.io/badge/Accessibility-98-green) | ![Best Practices](https://img.shields.io/badge/Best%20Practices-92-green) | ![SEO](https://img.shields.io/badge/SEO-100-green) | + | Docs | ![Performance](https://img.shields.io/badge/Performance-93-green) | ![Accessibility](https://img.shields.io/badge/Accessibility-96-green) | ![Best Practices](https://img.shields.io/badge/Best%20Practices-90-green) | ![SEO](https://img.shields.io/badge/SEO-98-green) | + | API | ![Performance](https://img.shields.io/badge/Performance-97-green) | ![Accessibility](https://img.shields.io/badge/Accessibility-94-green) | ![Best Practices](https://img.shields.io/badge/Best%20Practices-88-yellow) | ![SEO](https://img.shields.io/badge/SEO-96-green) | + + ## Key Metrics + + - **First Contentful Paint**: 0.8s + - **Largest Contentful Paint**: 1.2s + - **Cumulative Layout Shift**: 0.05 + - **Time to Interactive**: 1.5s + + ## Recommendations + + - ✅ Excellent performance scores + - ⚠️ Consider optimizing Best Practices on API page + - 🔍 Monitor mobile performance + + --- + + *Automated report generated by GitHub Actions* + EOF + + - name: Upload performance artifacts + uses: actions/upload-artifact@v3 + with: + name: performance-report + path: | + performance-report.md + .lighthouseci/ + + uptime-check: + name: Uptime and Health Check + runs-on: ubuntu-latest + + steps: + - name: Check site availability + run: | + urls=( + "https://username.github.io" + "https://username.github.io/docs/" + "https://username.github.io/api/" + ) + + failed_urls=() + + for url in "${urls[@]}"; do + echo "Checking $url..." + + if ! curl -f -s -o /dev/null -w "%{http_code}" "$url" | grep -E "^(200|301|302)$" > /dev/null; then + failed_urls+=("$url") + echo "❌ $url is not responding correctly" + else + echo "✅ $url is healthy" + fi + done + + if [ ${#failed_urls[@]} -gt 0 ]; then + echo "Failed URLs: ${failed_urls[*]}" + exit 1 + fi + + - name: SSL certificate check + run: | + echo "Checking SSL certificate validity..." + + domain="username.github.io" + expiry_date=$(openssl s_client -servername "$domain" -connect "$domain:443" 2>/dev/null | openssl x509 -noout -dates | grep notAfter | cut -d= -f2) + expiry_timestamp=$(date -d "$expiry_date" +%s) + current_timestamp=$(date +%s) + days_until_expiry=$(( (expiry_timestamp - current_timestamp) / 86400 )) + + echo "SSL certificate expires on: $expiry_date" + echo "Days until expiry: $days_until_expiry" + + if [ $days_until_expiry -lt 30 ]; then + echo "⚠️ SSL certificate expires in less than 30 days!" + exit 1 + else + echo "✅ SSL certificate is valid" + fi + + broken-links-check: + name: Broken Links Check + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + + - name: Install broken-link-checker + run: npm install -g broken-link-checker + + - name: Check for broken links + run: | + echo "Checking for broken links..." + + blc https://username.github.io \ + --recursive \ + --ordered \ + --exclude-external \ + --filter-level 2 \ + --get \ + --input + + - name: Create issue for broken links + if: failure() + uses: actions/github-script@v6 + with: + script: | + const title = '🔗 Broken Links Detected'; + const body = ` + ## 🔗 Broken Links Report + + The automated link checker has detected broken links on the website. + + **Check Time**: ${new Date().toISOString()} + **Workflow**: ${context.workflow} + **Run Number**: ${context.runNumber} + + ### Action Required + - [ ] Review the workflow logs for specific broken links + - [ ] Fix or remove broken links + - [ ] Update redirects if necessary + + ### Prevention + - [ ] Add link validation to CI/CD pipeline + - [ ] Regular content audits + - [ ] Monitor external dependencies + + **Auto-generated by**: Site Monitoring Workflow + `; + + await github.rest.issues.create({ + owner: context.repo.owner, + repo: context.repo.repo, + title: title, + body: body, + labels: ['bug', 'website', 'broken-links'] + }); + + security-headers-check: + name: Security Headers Validation + runs-on: ubuntu-latest + + steps: + - name: Check security headers + run: | + echo "Checking security headers..." + + url="https://username.github.io" + headers=$(curl -s -I "$url") + + # 必須セキュリティヘッダーの確認 + required_headers=( + "X-Content-Type-Options" + "X-Frame-Options" + "X-XSS-Protection" + "Strict-Transport-Security" + ) + + missing_headers=() + + for header in "${required_headers[@]}"; do + if ! echo "$headers" | grep -i "$header" > /dev/null; then + missing_headers+=("$header") + fi + done + + if [ ${#missing_headers[@]} -gt 0 ]; then + echo "❌ Missing security headers: ${missing_headers[*]}" + exit 1 + else + echo "✅ All required security headers present" + fi +``` + +### 📈 アクセス解析・最適化 + +#### Google Analytics 4 統合 +```javascript +// assets/js/analytics.js +class AdvancedAnalytics { + constructor(gaId) { + this.gaId = gaId; + this.isProduction = window.location.hostname !== 'localhost'; + this.init(); + } + + init() { + if (!this.isProduction || !this.gaId) return; + + // Google Analytics 4 の読み込み + this.loadGA4(); + + // カスタムイベントの設定 + this.setupCustomEvents(); + + // パフォーマンス監視 + this.setupPerformanceTracking(); + + // エラー追跡 + this.setupErrorTracking(); + } + + loadGA4() { + // GA4 スクリプトの動的読み込み + const script = document.createElement('script'); + script.async = true; + script.src = `https://www.googletagmanager.com/gtag/js?id=${this.gaId}`; + document.head.appendChild(script); + + window.dataLayer = window.dataLayer || []; + function gtag(){dataLayer.push(arguments);} + gtag('js', new Date()); + gtag('config', this.gaId, { + // プライバシー設定 + anonymize_ip: true, + cookie_flags: 'SameSite=Strict;Secure', + // パフォーマンス監視 + custom_map: { + 'custom_parameter_1': 'page_load_time', + 'custom_parameter_2': 'user_engagement' + } + }); + + window.gtag = gtag; + } + + setupCustomEvents() { + // 外部リンククリック追跡 + document.addEventListener('click', (e) => { + const link = e.target.closest('a'); + if (link && link.hostname !== window.location.hostname) { + this.trackEvent('click', { + event_category: 'external_link', + event_label: link.href, + transport_type: 'beacon' + }); + } + }); + + // ダウンロード追跡 + document.addEventListener('click', (e) => { + const link = e.target.closest('a'); + if (link && this.isDownloadLink(link.href)) { + this.trackEvent('file_download', { + file_name: this.getFileName(link.href), + file_extension: this.getFileExtension(link.href), + transport_type: 'beacon' + }); + } + }); + + // スクロール深度追跡 + this.setupScrollTracking(); + + // 検索イベント追跡 + const searchInput = document.getElementById('site-search'); + if (searchInput) { + searchInput.addEventListener('search', (e) => { + this.trackEvent('search', { + search_term: e.target.value, + event_category: 'site_search' + }); + }); + } + } + + setupScrollTracking() { + let scrollDepths = [25, 50, 75, 90]; + let trackedDepths = new Set(); + + window.addEventListener('scroll', () => { + const scrollPercent = Math.round( + (window.scrollY / (document.body.scrollHeight - window.innerHeight)) * 100 + ); + + scrollDepths.forEach(depth => { + if (scrollPercent >= depth && !trackedDepths.has(depth)) { + trackedDepths.add(depth); + this.trackEvent('scroll', { + event_category: 'engagement', + event_label: `${depth}%`, + value: depth + }); + } + }); + }); + } + + setupPerformanceTracking() { + // Core Web Vitals 監視 + if ('web-vital' in window) { + import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { + getCLS(this.sendWebVital.bind(this)); + getFID(this.sendWebVital.bind(this)); + getFCP(this.sendWebVital.bind(this)); + getLCP(this.sendWebVital.bind(this)); + getTTFB(this.sendWebVital.bind(this)); + }); + } + + // Navigation Timing API + window.addEventListener('load', () => { + setTimeout(() => { + const timing = performance.getEntriesByType('navigation')[0]; + if (timing) { + this.trackEvent('page_timing', { + event_category: 'performance', + page_load_time: Math.round(timing.loadEventEnd - timing.fetchStart), + dom_ready_time: Math.round(timing.domContentLoadedEventEnd - timing.fetchStart), + first_byte_time: Math.round(timing.responseStart - timing.fetchStart) + }); + } + }, 1000); + }); + } + + sendWebVital(metric) { + this.trackEvent(metric.name, { + event_category: 'web_vitals', + value: Math.round(metric.value), + metric_id: metric.id, + metric_delta: metric.delta + }); + } + + setupErrorTracking() { + // JavaScript エラー追跡 + window.addEventListener('error', (e) => { + this.trackEvent('exception', { + description: `${e.message} at ${e.filename}:${e.lineno}:${e.colno}`, + fatal: false, + error_type: 'javascript_error' + }); + }); + + // Promise rejection 追跡 + window.addEventListener('unhandledrejection', (e) => { + this.trackEvent('exception', { + description: `Unhandled Promise Rejection: ${e.reason}`, + fatal: false, + error_type: 'promise_rejection' + }); + }); + } + + trackEvent(eventName, parameters = {}) { + if (!this.isProduction || typeof gtag === 'undefined') return; + + gtag('event', eventName, { + event_timestamp: Date.now(), + page_title: document.title, + page_location: window.location.href, + ...parameters + }); + } + + isDownloadLink(href) { + const downloadExtensions = /\.(pdf|doc|docx|xls|xlsx|ppt|pptx|zip|rar|mp3|mp4|avi|mov)$/i; + return downloadExtensions.test(href); + } + + getFileName(href) { + return href.split('/').pop().split('?')[0]; + } + + getFileExtension(href) { + return href.split('.').pop().split('?')[0].toLowerCase(); + } +} + +// 初期化 +document.addEventListener('DOMContentLoaded', () => { + const gaId = document.querySelector('meta[name="google-analytics"]')?.content; + if (gaId) { + new AdvancedAnalytics(gaId); + } +}); +``` + +--- + +## 🎓 実践演習 + +### 演習1: 企業レベルWebサイト構築 +1. **多機能サイト** - Jekyll/Hugo/Next.js選択と実装 +2. **PWA対応** - Service Worker・Web App Manifest +3. **パフォーマンス最適化** - 画像最適化・CDN活用 +4. **SEO対策** - 構造化データ・メタタグ最適化 + +### 演習2: 外部サービス移行プロジェクト +1. **現状分析** - WordPress/他サービスの機能調査 +2. **移行戦略** - データ移行・機能代替・リスク評価 +3. **段階移行** - 並行運用・段階的切り替え +4. **運用最適化** - 監視・メンテナンス・改善 + +### 演習3: 高可用性Webサイト運用 +1. **監視体制** - パフォーマンス・稼働率・セキュリティ +2. **自動化** - デプロイ・バックアップ・復旧 +3. **スケーリング** - CDN・キャッシュ戦略 +4. **継続改善** - A/Bテスト・ユーザーフィードバック + +--- + +## 🔗 関連リソース + +### 公式ドキュメント +- [GitHub Pages Documentation](https://docs.github.com/en/pages) +- [Jekyll Documentation](https://jekyllrb.com/docs/) +- [Hugo Documentation](https://gohugo.io/documentation/) + +### パフォーマンス・SEOツール +- [Lighthouse](https://developers.google.com/web/tools/lighthouse) +- [PageSpeed Insights](https://pagespeed.web.dev/) +- [Web.dev](https://web.dev/) + +### 静的サイトジェネレーター +- [Gatsby](https://www.gatsbyjs.com/) +- [Next.js](https://nextjs.org/docs/advanced-features/static-html-export) +- [Nuxt.js](https://nuxtjs.org/docs/get-started/commands#static-deployment) + +--- + +## 📝 まとめ + +GitHub Pages を効果的に活用することで: + +✅ **外部サービス不要** - WordPress・Netlify等からの完全移行 +✅ **コスト大幅削減** - ホスティング・メンテナンス費用の最適化 +✅ **高性能・高可用性** - CDN・SSL・グローバル配信 +✅ **統合開発環境** - コードとWebサイトの一元管理 +✅ **スケーラビリティ** - 企業レベルの大規模サイト対応 + +これで主要なGitHub機能ガイドが完成しました!次はケーススタディとトレーニング資料を作成しましょう。 + +## 🔗 関連ガイド + +- **前のステップ**: [GitHub Security編](06-github-security.md) - セキュアなWebサイト・セキュリティ強化 +- **基礎知識**: [GitHub Actions編](05-github-actions.md) - CI/CDパイプライン構築 +- **プロジェクト管理**: [GitHub Projects編](04-github-projects.md) - 統合開発管理 +- **開発基礎**: [Pull Request編](03-pull-requests.md) - 協調開発・レビュープロセス +- **総合ガイド**: [GitHub完全活用ガイド](../GITHUB_COMPLETE_GUIDE.md) - 全機能の詳細解説 + +## 📖 学習フロー + +```mermaid +graph LR + A[リポジトリ基礎] --> B[Issues管理] + B --> C[Pull Request] + C --> D[GitHub Projects] + D --> E[GitHub Actions] + E --> F[Security] + F --> G[Pages] + G --> H[完全活用] + + style A fill:#f3e5f5 + style B fill:#f3e5f5 + style C fill:#f3e5f5 + style D fill:#f3e5f5 + style E fill:#f3e5f5 + style F fill:#f3e5f5 + style G fill:#e1f5fe + style H fill:#e8f5e8 +``` \ No newline at end of file diff --git a/index.md b/index.md index 2ec4652..0dcd642 100644 --- a/index.md +++ b/index.md @@ -60,24 +60,42 @@ description: "外部ツールに依存せず、GitHub一つで開発業務を完

📋 GitHub Projects

アジャイル開発のためのプロジェクト管理

+ + +

⚡ GitHub Actions

+

Jenkins・CircleCI代替のCI/CD自動化

+
+ + +

🛡️ GitHub Security

+

企業レベルの総合セキュリティ対策

+
+ + +

🌐 GitHub Pages

+

高機能Webサイト・ドキュメント公開

+
## 🎓 学習の進め方 -### 初心者の方 +### 🔰 初心者の方 1. **[リポジトリ基礎](features/01-repository-basics.html)** で基本操作を習得 2. **[Issues管理](features/02-issues-management.html)** でタスク管理を体験 -3. **[完全ガイド](GITHUB_COMPLETE_GUIDE.html)** で全体像を把握 +3. **[Pull Request](features/03-pull-requests.html)** でコードレビュー学習 +4. **[完全ガイド](GITHUB_COMPLETE_GUIDE.html)** で全体像を把握 -### 経験者の方 -1. **[完全ガイド](GITHUB_COMPLETE_GUIDE.html)** で新機能をチェック +### 👨‍💻 開発者・経験者の方 +1. **[GitHub Actions](features/05-github-actions.html)** でCI/CD自動化を習得 +2. **[GitHub Security](features/06-github-security.html)** でセキュリティ対策を強化 +3. **[GitHub Pages](features/07-github-pages.html)** でWebサイト・ドキュメント公開 +4. **[GitHub Projects](features/04-github-projects.html)** でアジャイル開発実践 + +### 👔 チームリーダー・意思決定者の方 +1. **[完全ガイド](GITHUB_COMPLETE_GUIDE.html)** でコスト分析・ROI検討 2. **外部ツール代替戦略** で移行計画を立案 -3. **実務ケーススタディ** で最適な導入方法を選択 - -### チームリーダーの方 -1. **コスト分析** で導入効果を試算 -2. **段階的移行計画** でリスクを最小化 -3. **実装チェックリスト** で確実な導入を実現 +3. **段階的移行計画** でリスク最小化 +4. **実装チェックリスト** で確実な導入を実現 ## 🎉 導入効果の実例 From 4430911181de3ddd00e45fd874d03230f5d1cd8c Mon Sep 17 00:00:00 2001 From: marketing-shibata50 Date: Sun, 20 Jul 2025 15:39:38 +0900 Subject: [PATCH 03/18] =?UTF-8?q?=E5=88=9D=E5=BF=83=E8=80=85=E5=90=91?= =?UTF-8?q?=E3=81=91=E3=82=B3=E3=83=B3=E3=83=86=E3=83=B3=E3=83=84=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - GitHub機能一覧シンプルガイドを追加 - 超初心者向けGitHub入門ガイドを追加 - 画面を見ながら操作できる実践ガイドを追加 - index.mdに初心者向けセクションを追加し、上部に配置 ユーザーフィードバックに基づき、技術的な内容から 初心者にやさしい基本的な使い方説明にシフト 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- beginners/github-beginner-guide.md | 272 +++++++++++++++++++++ beginners/github-features-simple.md | 262 ++++++++++++++++++++ beginners/github-hands-on.md | 360 ++++++++++++++++++++++++++++ index.md | 100 +++++++- 4 files changed, 991 insertions(+), 3 deletions(-) create mode 100644 beginners/github-beginner-guide.md create mode 100644 beginners/github-features-simple.md create mode 100644 beginners/github-hands-on.md diff --git a/beginners/github-beginner-guide.md b/beginners/github-beginner-guide.md new file mode 100644 index 0000000..f893a70 --- /dev/null +++ b/beginners/github-beginner-guide.md @@ -0,0 +1,272 @@ +--- +layout: default +title: "はじめてのGitHub - 超初心者向けガイド" +description: "GitHubを今から始める人のための、やさしい入門ガイド" +--- + +# 🌱 はじめてのGitHub - 超初心者向けガイド + +プログラミングの知識ゼロでも大丈夫!GitHubの使い方を、一番簡単なところから説明します。 + +--- + +## 📝 このガイドで学べること + +- GitHubって何? +- アカウントの作り方 +- 最初のプロジェクト作成 +- ファイルの保存と管理 +- 他の人と協力する方法 + +--- + +## 🤔 そもそもGitHubって何? + +### 簡単に言うと... +**GitHubは「ファイルを保存して、みんなで共有できるサービス」です。** + +### 例えば、こんな使い方ができます +- 📝 **文書管理** - マニュアルや資料を管理 +- 💻 **コード管理** - プログラムを保存 +- 🎨 **デザイン管理** - 画像やデザインファイル +- 📊 **データ管理** - CSVやExcelファイル +- 📚 **学習記録** - 勉強したことをまとめる + +### GitHubの3つの特徴 +1. **履歴が残る** - いつ、誰が、何を変更したか全部記録 +2. **元に戻せる** - 失敗しても前の状態に戻せる +3. **みんなで使える** - チームで同じファイルを編集できる + +--- + +## 🚀 STEP 1: アカウントを作ろう + +### 1. GitHubにアクセス +[https://github.com](https://github.com) を開く + +### 2. Sign up(サインアップ)をクリック +右上の「Sign up」ボタンをクリック + +### 3. 必要な情報を入力 +- **Username(ユーザー名)**: 好きな名前(英数字) +- **Email(メールアドレス)**: 普段使うメール +- **Password(パスワード)**: 8文字以上 + +### 4. 検証を完了 +- パズルを解く(ロボットじゃないことを証明) +- メールに届いた数字を入力 + +**🎉 完成!これでGitHubが使えます!** + +--- + +## 📁 STEP 2: 最初のリポジトリを作ろう + +### リポジトリって何? +**リポジトリ = プロジェクトの保存場所** +(フォルダみたいなもの) + +### 作り方 +1. **右上の「+」ボタン** → **「New repository」** + +2. **必要事項を入力** + - **Repository name**: プロジェクトの名前 + - 例:`my-first-project`、`hello-world` + - **Description**: プロジェクトの説明(省略OK) + - 例:「GitHubの練習用プロジェクト」 + - **Public/Private**: 公開設定 + - **Public**: みんなに公開(無料) + - **Private**: 自分だけ(無料) + +3. **初期設定**(チェックを入れる) + - ✅ **Add a README file**: 説明ファイルを作る + - ✅ **Add .gitignore**: 無視するファイルの設定 + - ✅ **Choose a license**: ライセンス(後で考えてOK) + +4. **「Create repository」をクリック** + +**🎊 リポジトリ完成!** + +--- + +## 📝 STEP 3: ファイルを追加してみよう + +### 方法1: ブラウザで直接作成 +1. **「Add file」** → **「Create new file」** +2. **ファイル名を入力** + - 例:`memo.txt`、`diary.md` +3. **内容を入力** + ``` + 今日のメモ + + GitHubを始めました! + 思ったより簡単でした。 + ``` +4. **下の方にある「Commit new file」をクリック** + +### 方法2: ファイルをアップロード +1. **「Add file」** → **「Upload files」** +2. **ファイルをドラッグ&ドロップ** +3. **「Commit changes」をクリック** + +### 💡 Commit(コミット)って何? +**Commit = 変更を保存すること** +- セーブみたいなもの +- 変更内容にメッセージを付けられる +- 後で見返しやすい + +--- + +## ✏️ STEP 4: ファイルを編集しよう + +### 編集の手順 +1. **編集したいファイルをクリック** +2. **鉛筆アイコン(✏️)をクリック** +3. **内容を変更** +4. **下にスクロールして「Commit changes」** + - **メッセージを入力**(例:「日付を追加」) + - **「Commit changes」をクリック** + +### 変更履歴を見る +1. **ファイル名の横の「History」をクリック** +2. **いつ、何を変更したか一覧で見れる** +3. **各変更をクリックすると詳細が見れる** + +--- + +## 👥 STEP 5: 他の人と協力しよう(基本編) + +### Issues(イシュー)を使った連絡 +**Issues = 連絡帳・TODO リスト** + +#### 作り方 +1. **「Issues」タブをクリック** +2. **「New issue」をクリック** +3. **タイトルと内容を入力** + - タイトル例:「README に使い方を追加してください」 + - 内容例:「初めての人向けの説明を追加したいです」 +4. **「Submit new issue」をクリック** + +#### 返信の仕方 +1. **Issueを開く** +2. **下のコメント欄に返信を書く** +3. **「Comment」をクリック** + +### 他の人のプロジェクトを見る +1. **検索バーにキーワードを入力** + - 例:「recipe」「todo」「diary」 +2. **気になるプロジェクトをクリック** +3. **⭐Star を付けてお気に入り登録** + +--- + +## 💡 知っておくと便利な機能 + +### 📝 README.md(リードミー) +- **プロジェクトの説明書** +- **最初に表示される** +- **Markdown(マークダウン)で書ける** + +#### 簡単なMarkdown記法 +```markdown +# 大見出し +## 中見出し +### 小見出し + +- 箇条書き1 +- 箇条書き2 + +**太字** +*斜体* + +[リンク](https://github.com) +``` + +### 🔒 公開/非公開の切り替え +1. **Settings(設定)** +2. **一番下の「Danger Zone」** +3. **「Change visibility」** + +### 📊 プロジェクトの統計 +- **Insights タブ**で色々な統計が見れる +- **誰が**、**いつ**、**どれくらい**活動したか + +--- + +## 🎯 練習課題 + +### レベル1:基本操作 +1. ✅ アカウントを作る +2. ✅ リポジトリを作る +3. ✅ README.md を編集する +4. ✅ 新しいファイルを追加する + +### レベル2:ファイル管理 +1. ✅ フォルダを作る(ファイル名に`/`を使う) +2. ✅ 画像をアップロードする +3. ✅ ファイルを削除する +4. ✅ 変更履歴を確認する + +### レベル3:コミュニケーション +1. ✅ Issue を作る +2. ✅ Issue にコメントする +3. ✅ 他の人のリポジトリに Star を付ける +4. ✅ 面白いプロジェクトを3つ見つける + +--- + +## ❓ よくある質問と回答 + +### Q: 英語が苦手でも大丈夫? +**A: 大丈夫です!** +- 基本的な単語だけ覚えればOK +- Google翻訳を使いながらでもOK +- 日本語でファイルを作ってもOK + +### Q: 間違えて消しちゃったらどうしよう? +**A: 大丈夫!履歴から復元できます** +1. History を見る +2. 消す前の状態を選ぶ +3. 復元する + +### Q: みんなに見られるのが恥ずかしい +**A: Private(非公開)にすればOK!** +- 後から公開に変更もできる +- 最初は非公開で練習がおすすめ + +### Q: 何を作ればいいかわからない +**A: こんなものから始めてみては?** +- 日記 +- 勉強メモ +- レシピ集 +- 読書記録 +- TODO リスト + +--- + +## 🚀 次のステップ + +### もう少し慣れたら... +1. **ブランチ**を使ってみる(安全に実験できる) +2. **Pull Request**を体験する(変更の提案) +3. **GitHub Pages**でWebサイトを作る + +### 学習リソース +- [GitHub公式の日本語ガイド](https://docs.github.com/ja) +- [実践的な操作手順ガイド](github-hands-on.md) + +--- + +## 🎉 おめでとうございます! + +ここまで読んだあなたは、もうGitHubの基本が使えるようになっています! + +**覚えておいてほしいこと:** +- 💪 **最初は誰でも初心者** +- 🔄 **失敗しても戻せる** +- 📈 **使えば使うほど上達する** +- 🤝 **分からないことは聞いてOK** + +**まずは1つ、何かファイルを保存してみることから始めましょう!** + +Happy GitHub Life! 🌟 \ No newline at end of file diff --git a/beginners/github-features-simple.md b/beginners/github-features-simple.md new file mode 100644 index 0000000..daa615b --- /dev/null +++ b/beginners/github-features-simple.md @@ -0,0 +1,262 @@ +--- +layout: default +title: "GitHub機能一覧 - シンプルガイド" +description: "GitHubで何ができるの?機能一覧と簡単な使い方" +--- + +# 🌟 GitHubの機能一覧 - 何ができるの? + +GitHubって何ができるの?という疑問に、シンプルにお答えします! + +--- + +## 📌 GitHubの主な機能一覧 + +### 1. 📁 **リポジトリ(Repository)** +**何これ?** → プロジェクトを保存する場所 +**何ができる?** +- コードやファイルを保存 +- 変更履歴を記録 +- 複数人で共有 + +**使い方:** +1. 右上の「+」ボタン → 「New repository」 +2. 名前を入力(例:my-first-project) +3. 「Create repository」をクリック + +--- + +### 2. 🌿 **ブランチ(Branch)** +**何これ?** → 作業を分ける仕組み +**何ができる?** +- 本番に影響せずに開発 +- 複数の機能を並行開発 +- 安全に実験 + +**使い方:** +1. リポジトリページの「main」ボタンをクリック +2. 新しいブランチ名を入力(例:new-feature) +3. 「Create branch」をクリック + +--- + +### 3. 💾 **コミット(Commit)** +**何これ?** → 変更を保存すること +**何ができる?** +- ファイルの変更を記録 +- いつ誰が何を変更したか分かる +- 過去の状態に戻せる + +**使い方:** +1. ファイルを編集 +2. 「Commit changes」ボタンをクリック +3. 変更内容を説明(例:「ログイン機能を追加」) +4. 「Commit changes」で保存 + +--- + +### 4. 🔄 **プルリクエスト(Pull Request)** +**何これ?** → 変更を提案する仕組み +**何ができる?** +- コードレビューを依頼 +- 変更内容を説明 +- 議論しながら改善 + +**使い方:** +1. 「Pull requests」タブ → 「New pull request」 +2. 比較するブランチを選択 +3. タイトルと説明を入力 +4. 「Create pull request」をクリック + +--- + +### 5. 🎫 **イシュー(Issues)** +**何これ?** → タスク管理・バグ報告 +**何ができる?** +- やることリストを作成 +- バグを報告 +- アイデアを共有 + +**使い方:** +1. 「Issues」タブ → 「New issue」 +2. タイトル(例:「ログインボタンが動かない」) +3. 詳細を説明 +4. 「Submit new issue」をクリック + +--- + +### 6. 📋 **プロジェクト(Projects)** +**何これ?** → タスクボード +**何ができる?** +- タスクを視覚的に管理 +- 進捗状況を確認 +- チームで協力 + +**使い方:** +1. 「Projects」タブ → 「New project」 +2. ボード形式を選択 +3. タスクカードを追加 +4. ドラッグ&ドロップで移動 + +--- + +### 7. ⚡ **アクション(Actions)** +**何これ?** → 自動化ツール +**何ができる?** +- テストを自動実行 +- デプロイを自動化 +- 定期的なタスクを実行 + +**使い方:** +1. 「Actions」タブ +2. 「set up a workflow yourself」 +3. テンプレートを選択 +4. 「Start commit」で保存 + +--- + +### 8. 🌐 **ページ(Pages)** +**何これ?** → 無料のWebサイト公開 +**何ができる?** +- Webサイトを公開 +- ドキュメントを公開 +- ポートフォリオ作成 + +**使い方:** +1. Settings → Pages +2. Source で「Deploy from a branch」選択 +3. Branch を「main」に設定 +4. 「Save」をクリック + +--- + +### 9. 📚 **ウィキ(Wiki)** +**何これ?** → プロジェクトの説明書 +**何ができる?** +- ドキュメント作成 +- 使い方マニュアル +- FAQ作成 + +**使い方:** +1. 「Wiki」タブ +2. 「Create the first page」 +3. 内容を入力 +4. 「Save page」 + +--- + +### 10. 👁️ **ウォッチ(Watch)** +**何これ?** → 更新通知を受け取る +**何ができる?** +- プロジェクトの更新を追跡 +- 重要な変更を見逃さない +- 興味のあるプロジェクトをフォロー + +**使い方:** +1. リポジトリページの「Watch」ボタン +2. 通知レベルを選択 +3. 「Apply」をクリック + +--- + +### 11. ⭐ **スター(Star)** +**何これ?** → お気に入り登録 +**何ができる?** +- 気に入ったプロジェクトを保存 +- 後で見返せる +- 作者を応援 + +**使い方:** +1. リポジトリページの「Star」ボタンをクリック +2. それだけ! + +--- + +### 12. 🍴 **フォーク(Fork)** +**何これ?** → プロジェクトをコピー +**何ができる?** +- 他人のプロジェクトをコピー +- 自分用にカスタマイズ +- 改善案を提案 + +**使い方:** +1. リポジトリページの「Fork」ボタン +2. 自分のアカウントにコピーされる +3. 自由に編集可能 + +--- + +## 🎯 どの機能から始めるべき? + +### 🔰 完全初心者の方 +1. **リポジトリ作成** - まず保存場所を作る +2. **ファイルアップロード** - 簡単なファイルを追加 +3. **コミット** - 変更を保存してみる + +### 📝 ドキュメント管理したい方 +1. **リポジトリ作成** +2. **Wiki** or **Pages** - ドキュメント公開 +3. **Issues** - フィードバック受付 + +### 👥 チーム開発したい方 +1. **リポジトリ作成** +2. **ブランチ** - 作業を分ける +3. **Pull Request** - レビューする +4. **Projects** - タスク管理 + +--- + +## 💡 覚えておくと便利なこと + +### 📌 よく使うボタンの場所 +- **新規作成**: 右上の「+」ボタン +- **設定**: リポジトリの「Settings」タブ +- **ファイル追加**: 「Add file」ボタン +- **編集**: ファイルの鉛筆アイコン + +### 🔍 便利なショートカット +- `t` - ファイル検索 +- `b` - ブランチ切り替え +- `w` - ブランチ選択 +- `s` - 検索にフォーカス + +### 💬 基本的な用語 +- **Clone(クローン)**: リポジトリをダウンロード +- **Push(プッシュ)**: 変更をアップロード +- **Pull(プル)**: 最新版をダウンロード +- **Merge(マージ)**: 変更を統合 + +--- + +## 🚀 次のステップ + +1. **アカウント作成** - まだの方は[GitHub.com](https://github.com)で無料登録 +2. **最初のリポジトリ** - 「Hello World」を作ってみる +3. **README作成** - プロジェクトの説明を書く +4. **Issues体験** - 自分でタスクを作ってみる + +--- + +## ❓ よくある質問 + +**Q: 無料で使える?** +A: はい!個人利用は基本無料です。 + +**Q: プログラミングできなくても使える?** +A: はい!ドキュメント管理やタスク管理にも使えます。 + +**Q: 公開しないといけない?** +A: いいえ!プライベートリポジトリで非公開にできます。 + +**Q: 日本語は使える?** +A: はい!ファイル名以外は日本語OK。 + +--- + +## 📚 もっと詳しく知りたい方へ + +各機能の詳しい使い方は、個別のガイドをご覧ください: +- [初心者向け入門ガイド](github-beginner-guide.md) +- [実践的な操作手順](github-hands-on.md) + +でも、まずは**リポジトリを作って、何か保存してみる**ことから始めましょう!🎉 \ No newline at end of file diff --git a/beginners/github-hands-on.md b/beginners/github-hands-on.md new file mode 100644 index 0000000..d535a25 --- /dev/null +++ b/beginners/github-hands-on.md @@ -0,0 +1,360 @@ +--- +layout: default +title: "GitHub実践ガイド - 画面を見ながら操作しよう" +description: "実際の画面を見ながら、GitHubの基本操作をマスターしよう" +--- + +# 🖥️ GitHub実践ガイド - 画面を見ながら操作しよう + +実際の画面を想定しながら、一つずつ操作を覚えていきましょう! + +--- + +## 📍 画面の見方を覚えよう + +### GitHub トップページ +``` +┌─────────────────────────────────────────────────┐ +│ 🐙 GitHub 検索バー [___________] 🔔 ➕ 👤 │ +├─────────────────────────────────────────────────┤ +│ │ +│ 左側: 右側: │ +│ 📁 Recent Repositories 📰 最近の活動 │ +│ - my-first-project - @user がスター │ +│ - hello-world - 新しいissue │ +│ │ +└─────────────────────────────────────────────────┘ +``` + +**重要なボタンの位置:** +- 🔔 **通知** - 更新があったら赤い丸が付く +- ➕ **新規作成** - ここから新しいものを作る +- 👤 **プロフィール** - 設定やログアウト + +--- + +## 🎯 実践1:リポジトリを作る + +### 手順1:新規作成ボタンをクリック +``` +画面右上 + ↓ + [ 🔔 ] [ ➕ ] [ 👤 ] + ↑ + ここをクリック! +``` + +### 手順2:メニューから選択 +``` +┌─────────────────┐ +│ New repository │ ← これを選ぶ +│ Import repo... │ +│ New gist │ +│ New org... │ +└─────────────────┘ +``` + +### 手順3:リポジトリ情報を入力 +``` +Create a new repository +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Repository name * +[my-awesome-project_______________] + ↑ + 半角英数字とハイフン(-)が使える + +Description (optional) +[私の素晴らしいプロジェクト_________] + ↑ + 日本語OK! + +◉ Public ○ Private + ↑ ↑ +みんなに公開 自分だけ + +□ Add a README file ← チェックを入れる! +□ Add .gitignore +□ Choose a license + +[Create repository] ← 最後にこれをクリック +``` + +--- + +## 🎯 実践2:ファイルを作成・編集 + +### 新しいファイルを作る + +#### 手順1:Add fileボタンを探す +``` +リポジトリページ +┌─────────────────────────────────────────────┐ +│ 📁 my-awesome-project │ +│ ─────────────────────────────────────────── │ +│ 📄 README.md │ +│ │ +│ [Add file ▼] [🟢 Code ▼] │ +│ ↑ │ +│ ここをクリック │ +└─────────────────────────────────────────────┘ +``` + +#### 手順2:Create new fileを選択 +``` +┌──────────────────┐ +│ Create new file │ ← これ +│ Upload files │ +└──────────────────┘ +``` + +#### 手順3:ファイル名と内容を入力 +``` +ファイル作成画面 +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +my-awesome-project / [memo.txt___________] + ↑ + ファイル名を入力 + +Edit new file Preview +━━━━━━━━━━━━━━━━━━━━━━━ +1 | 今日の作業メモ +2 | +3 | GitHubの使い方を勉強中 +4 | 思ったより簡単だった! +5 | + ↑ + 内容を入力 +``` + +#### 手順4:保存(コミット) +``` +画面下部 +━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Commit new file + +[メモファイルを追加_______________] + ↑ + 何をしたか書く(日本語OK) + +◉ Commit directly to the main branch +○ Create a new branch + +[Commit new file] ← クリックして保存 +``` + +--- + +## 🎯 実践3:既存ファイルを編集 + +### 手順1:編集したいファイルをクリック +``` +ファイル一覧 +━━━━━━━━━━━━━━━━━━━━ +📄 README.md ← クリック +📄 memo.txt +``` + +### 手順2:編集ボタンをクリック +``` +ファイル表示画面 +┌─────────────────────────────────────┐ +│ README.md ✏️ 🗑️ │ +│ ↑ │ +│ 鉛筆マーク │ +│ ─────────────────────────────────── │ +│ # my-awesome-project │ +│ 私の素晴らしいプロジェクト │ +└─────────────────────────────────────┘ +``` + +### 手順3:編集して保存 +``` +編集画面 +━━━━━━━━━━━━━━━━━━━━━ +1 | # my-awesome-project +2 | 私の素晴らしいプロジェクト +3 | +4 | ## 今日やったこと ← 追加 +5 | - GitHubの勉強 ← 追加 +6 | + +下にスクロールして... + +[Commit changes] をクリック +``` + +--- + +## 🎯 実践4:Issue(タスク)を作る + +### 手順1:Issuesタブをクリック +``` +リポジトリ上部のタブ +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +<> Code | 🔴 Issues | 🔄 PR | ⚡ Actions + ↑ + ここをクリック +``` + +### 手順2:New issueをクリック +``` +Issues画面 +┌──────────────────────────────────┐ +│ 🔍 検索バー [New issue] │ +│ ↑ │ +│ 緑のボタン │ +└──────────────────────────────────┘ +``` + +### 手順3:タイトルと内容を書く +``` +新規Issue作成 +━━━━━━━━━━━━━━━━━━━━━━━━━━━ + +Title +[READMEに使い方を追加したい_______] + ↑ + やりたいこと + +Leave a comment +┌─────────────────────────────┐ +│ ## やりたいこと │ +│ READMEに初心者向けの │ +│ 使い方を追加したいです │ +│ │ +│ ## 理由 │ +│ 友達に教えるときに │ +│ 説明しやすくするため │ +└─────────────────────────────┘ + +[Submit new issue] ← クリック +``` + +--- + +## 🎯 実践5:他の人のプロジェクトを見る + +### 手順1:検索する +``` +画面上部の検索バー +┌────────────────────────────┐ +│ 🔍 Search GitHub │ +└────────────────────────────┘ + ↑ + 「recipe」「diary」など + 興味のあるキーワードを入力 +``` + +### 手順2:検索結果から選ぶ +``` +検索結果 +━━━━━━━━━━━━━━━━━━━━━━━━━ + +📁 user/recipe-collection ⭐ 234 + 簡単レシピ集 + +📁 another/my-recipes ⭐ 89 + 毎日の料理レシピ + ↑ + 気になるものをクリック +``` + +### 手順3:スターを付ける +``` +プロジェクトページ +┌────────────────────────────────────┐ +│ 📁 user/recipe-collection │ +│ │ +│ [⭐ Star] [👁️ Watch] [🍴 Fork] │ +│ ↑ │ +│ クリックでお気に入り登録 │ +└────────────────────────────────────┘ +``` + +--- + +## 💡 操作のコツ + +### 🔍 迷ったときは +1. **戻るボタン** - ブラウザの戻るで大丈夫 +2. **ロゴクリック** - GitHubロゴでトップに戻る +3. **パンくずリスト** - 今どこにいるか分かる + +### ⌨️ 便利なキーボードショートカット +画面で `?` を押すと、ショートカット一覧が出ます! + +よく使うもの: +- `t` - ファイル検索 +- `b` - ブランチ切り替え +- `g` `n` - 通知ページへ +- `g` `d` - ダッシュボードへ + +### 🎨 見た目を変える +プロフィール → Settings → Appearance で: +- ☀️ **Light** - 明るいテーマ +- 🌙 **Dark** - 暗いテーマ +- 💻 **System** - OSに合わせる + +--- + +## 🚨 困ったときの対処法 + +### ❌ エラーが出た +``` +エラー例: +┌─────────────────────────────┐ +│ ⚠️ File name already exists │ +└─────────────────────────────┘ +``` +**対処法**: ファイル名を変える + +### 🔒 Permission denied +**対処法**: ログインし直す、権限を確認 + +### 📝 日本語が文字化け +**対処法**: ファイルの文字コードをUTF-8に + +--- + +## 🎓 練習問題 + +### 📌 基本操作をマスターしよう + +#### 課題1:自己紹介リポジトリ +1. `self-introduction` という名前でリポジトリ作成 +2. `profile.md` ファイルを作成 +3. 自己紹介を書く +4. `hobbies.md` を追加して趣味を書く + +#### 課題2:日記リポジトリ +1. `my-diary-2024` でリポジトリ作成 +2. `2024/01/diary.md` を作成(フォルダ付き) +3. 今日の出来事を書く +4. Issue で「明日やること」を作成 + +#### 課題3:学習記録 +1. `learning-log` でリポジトリ作成 +2. `github/` フォルダを作る +3. `day1.md` に今日学んだことを記録 +4. README.md に目次を追加 + +--- + +## 🎉 よくできました! + +ここまでできたら、GitHubの基本操作はバッチリです! + +**次のステップ:** +- 🌿 ブランチを使った安全な編集 +- 🔄 Pull Requestでの共同作業 +- 🌐 GitHub Pagesでサイト公開 + +**覚えておいてください:** +- 😊 間違えても大丈夫、やり直せます +- 📚 分からないことは調べながらでOK +- 🎯 毎日少しずつ使えば必ず上達します + +楽しいGitHubライフを! 🚀 \ No newline at end of file diff --git a/index.md b/index.md index 0dcd642..302a316 100644 --- a/index.md +++ b/index.md @@ -6,7 +6,34 @@ description: "外部ツールに依存せず、GitHub一つで開発業務を完 # 🚀 GitHub完全活用ガイド -> **GitHub機能を網羅的に理解し、開発プロセスを最適化するための実践的解説書** +> **GitHubって何?から始める、初心者からプロまで使える完全ガイド** + +## 🌱 初めての方はこちらから! + +

🎯 このサイトで学べること

@@ -260,20 +287,87 @@ gh issue create --title "プロジェクト初期設定" --body "GitHub機能の color: white; } +/* 初心者セクション */ +.beginner-section { + background: #e3f2fd; + padding: 2rem; + border-radius: 10px; + margin: 2rem 0; + text-align: center; +} + +.beginner-section h2 { + color: #1976d2; + margin-bottom: 1rem; +} + +.beginner-links { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); + gap: 1.5rem; + margin-top: 2rem; +} + +.beginner-card { + background: white; + padding: 2rem; + border-radius: 8px; + text-decoration: none; + color: inherit; + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); + transition: all 0.3s ease; + position: relative; + overflow: hidden; +} + +.beginner-card:hover { + transform: translateY(-3px); + box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15); + text-decoration: none; +} + +.beginner-card h3 { + color: #1976d2; + margin-bottom: 0.5rem; + font-size: 1.3rem; +} + +.beginner-card p { + color: #424242; + line-height: 1.6; + margin-bottom: 1rem; +} + +.beginner-card .time { + display: inline-block; + background: #e3f2fd; + color: #1565c0; + padding: 0.3rem 0.8rem; + border-radius: 20px; + font-size: 0.85rem; + font-weight: 500; +} + /* レスポンシブ対応 */ @media (max-width: 768px) { .features-grid, .guide-links, - .stats-section { + .stats-section, + .beginner-links { grid-template-columns: 1fr; } - .hero-section { + .hero-section, + .beginner-section { padding: 1.5rem; } .stat-item h3 { font-size: 2rem; } + + .beginner-card { + padding: 1.5rem; + } } \ No newline at end of file From 6cf449eaeb951953b4843542fb89998ac8733307 Mon Sep 17 00:00:00 2001 From: marketing-shibata50 Date: Sun, 20 Jul 2025 16:04:39 +0900 Subject: [PATCH 04/18] =?UTF-8?q?Git=20=E3=83=AF=E3=83=BC=E3=82=AF?= =?UTF-8?q?=E3=83=95=E3=83=AD=E3=83=BC=E3=82=AC=E3=82=A4=E3=83=89=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E3=81=97=E3=80=81=E6=A9=9F=E8=83=BD=E4=B8=80?= =?UTF-8?q?=E8=A6=A7=E3=82=9220=E5=80=8B=E3=81=AB=E6=8B=A1=E5=BC=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - github-features-simple.md: Git基本操作(Clone/Push/Pull/Merge)と追加機能を含む20機能に拡張 - github-git-workflow.md: 新規作成 - Clone→編集→Push→Pullの実際の作業フローを図解付きで解説 - index.md: 新しいワークフローガイドへのリンクを追加、機能数を12→20に更新 ユーザーからの「git workflowがない」というフィードバックに対応 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- beginners/github-features-simple.md | 125 ++++++++- beginners/github-git-workflow.md | 389 ++++++++++++++++++++++++++++ index.md | 10 +- 3 files changed, 521 insertions(+), 3 deletions(-) create mode 100644 beginners/github-git-workflow.md diff --git a/beginners/github-features-simple.md b/beginners/github-features-simple.md index daa615b..df8f9d5 100644 --- a/beginners/github-features-simple.md +++ b/beginners/github-features-simple.md @@ -10,7 +10,7 @@ GitHubって何ができるの?という疑問に、シンプルにお答え --- -## 📌 GitHubの主な機能一覧 +## 📌 GitHubの主な機能一覧(全20機能) ### 1. 📁 **リポジトリ(Repository)** **何これ?** → プロジェクトを保存する場所 @@ -186,6 +186,119 @@ GitHubって何ができるの?という疑問に、シンプルにお答え --- +### 13. 📥 **クローン(Clone)** +**何これ?** → リポジトリをパソコンにダウンロード +**何ができる?** +- GitHubからローカルPCへコピー +- オフラインで作業可能 +- 好きなエディタで編集 + +**使い方:** +1. リポジトリページの「Code」ボタン +2. URLをコピー +3. ターミナルで `git clone [URL]` +4. または GitHub Desktop でワンクリック + +--- + +### 14. ⬆️ **プッシュ(Push)** +**何これ?** → ローカルの変更をGitHubにアップロード +**何ができる?** +- 自分の作業を保存 +- チームメンバーと共有 +- バックアップ + +**使い方:** +1. ローカルで変更・コミット +2. `git push` コマンド実行 +3. または GitHub Desktop の「Push」ボタン + +--- + +### 15. ⬇️ **プル(Pull)** +**何これ?** → GitHubから最新の変更を取得 +**何ができる?** +- 他の人の変更を取り込む +- 最新版に更新 +- 競合を防ぐ + +**使い方:** +1. `git pull` コマンド実行 +2. または GitHub Desktop の「Pull」ボタン +3. 自動的に最新版に更新 + +--- + +### 16. 🔀 **マージ(Merge)** +**何これ?** → ブランチを統合 +**何ができる?** +- 機能開発を本番に反映 +- 複数の変更を一つに +- チームの作業を統合 + +**使い方:** +1. Pull Request を作成 +2. レビュー後「Merge」ボタン +3. ブランチが統合される + +--- + +### 17. 💬 **ディスカッション(Discussions)** +**何これ?** → フォーラム形式の議論場所 +**何ができる?** +- Q&A形式で質問 +- アイデアの議論 +- お知らせの共有 + +**使い方:** +1. 「Discussions」タブ +2. 「New discussion」 +3. カテゴリを選んで投稿 + +--- + +### 18. 📝 **ギスト(Gist)** +**何これ?** → コードスニペットの共有 +**何ができる?** +- 短いコードを共有 +- メモやスクリプト保存 +- 埋め込み可能 + +**使い方:** +1. gist.github.com にアクセス +2. コードを貼り付け +3. 「Create secret/public gist」 + +--- + +### 19. 📦 **パッケージ(Packages)** +**何これ?** → パッケージ管理 +**何ができる?** +- npmパッケージ公開 +- Dockerイメージ管理 +- 依存関係の管理 + +**使い方:** +1. リポジトリの「Packages」 +2. パッケージタイプを選択 +3. 公開手順に従う + +--- + +### 20. 💖 **スポンサー(Sponsors)** +**何これ?** → 開発者支援 +**何ができる?** +- オープンソース開発者を支援 +- 定期的な寄付 +- 特典の提供 + +**使い方:** +1. プロフィールの「Sponsor」ボタン +2. 支援額を選択 +3. 支払い方法を設定 + +--- + ## 🎯 どの機能から始めるべき? ### 🔰 完全初心者の方 @@ -204,6 +317,12 @@ GitHubって何ができるの?という疑問に、シンプルにお答え 3. **Pull Request** - レビューする 4. **Projects** - タスク管理 +### 💻 本格的に開発したい方 +1. **Clone** - リポジトリをダウンロード +2. **コミット** → **Push** - 変更をアップロード +3. **Pull** - 最新版を取得 +4. **Merge** - 変更を統合 + --- ## 💡 覚えておくと便利なこと @@ -225,6 +344,9 @@ GitHubって何ができるの?という疑問に、シンプルにお答え - **Push(プッシュ)**: 変更をアップロード - **Pull(プル)**: 最新版をダウンロード - **Merge(マージ)**: 変更を統合 +- **Fetch(フェッチ)**: 変更を確認だけ(取り込まない) +- **Remote(リモート)**: GitHub上のリポジトリ +- **Local(ローカル)**: 自分のPC上のリポジトリ --- @@ -258,5 +380,6 @@ A: はい!ファイル名以外は日本語OK。 各機能の詳しい使い方は、個別のガイドをご覧ください: - [初心者向け入門ガイド](github-beginner-guide.md) - [実践的な操作手順](github-hands-on.md) +- [Git ワークフローガイド](github-git-workflow.md) - Clone → 編集 → Push の流れ でも、まずは**リポジトリを作って、何か保存してみる**ことから始めましょう!🎉 \ No newline at end of file diff --git a/beginners/github-git-workflow.md b/beginners/github-git-workflow.md new file mode 100644 index 0000000..67007f8 --- /dev/null +++ b/beginners/github-git-workflow.md @@ -0,0 +1,389 @@ +--- +layout: default +title: "Git ワークフローガイド - 実際の作業の流れ" +description: "Clone → 編集 → Commit → Push → Pull の基本的な流れを図解で理解" +--- + +# 🔄 Git ワークフローガイド - 実際の作業の流れ + +GitHubを使った実際の作業の流れを、初心者でも分かるように図解付きで説明します! + +--- + +## 📝 このガイドで学べること + +- Git の基本的な作業の流れ +- ローカルとリモートの関係 +- よくあるワークフローパターン +- トラブル時の対処法 + +--- + +## 🌟 Git ワークフローとは? + +**簡単に言うと**: コードを書いて、保存して、共有するまでの一連の流れです。 + +``` +あなたのPC(ローカル) GitHub(リモート) + ↓ ↑ + 編集する みんなが見れる + ↓ ↑ + 保存する ←→ 共有する +``` + +--- + +## 🎯 基本的なワークフロー + +### 全体の流れ + +``` +1. Clone(クローン) - GitHubからダウンロード + ↓ +2. 編集 - ファイルを変更 + ↓ +3. Add(追加) - 変更を記録準備 + ↓ +4. Commit(コミット) - 変更を保存 + ↓ +5. Push(プッシュ) - GitHubにアップロード + ↓ +6. Pull(プル) - 最新版を取得 +``` + +--- + +## 📥 STEP 1: Clone(クローン)- 最初の一歩 + +### GitHubからプロジェクトをダウンロード + +#### 方法1: コマンドライン +```bash +# リポジトリをクローン +git clone https://github.com/ユーザー名/リポジトリ名.git + +# フォルダに移動 +cd リポジトリ名 +``` + +#### 方法2: GitHub Desktop +``` +1. リポジトリページの「Code」ボタン +2. 「Open with GitHub Desktop」を選択 +3. 保存場所を選んで「Clone」 +``` + +### 図解 +``` + GitHub あなたのPC +┌─────────────┐ ┌─────────────┐ +│ Repository │ Clone→ │ Local │ +│ (原本) │ ========> │ (コピー) │ +└─────────────┘ └─────────────┘ +``` + +--- + +## ✏️ STEP 2: 編集 - ファイルを変更 + +### 好きなエディタで編集 + +``` +作業フォルダ +├── README.md ← これを編集 +├── index.html ← 新しく作成 +└── style.css ← これも編集 +``` + +**ポイント**: +- どのエディタでもOK(VSCode、メモ帳、など) +- 普通にファイルを編集するだけ +- 保存を忘れずに! + +--- + +## 📋 STEP 3: Add(追加)- 変更を記録準備 + +### 変更したファイルを記録対象に追加 + +#### コマンドライン +```bash +# 特定のファイルを追加 +git add README.md + +# すべての変更を追加 +git add . +``` + +#### GitHub Desktop +- 変更されたファイルが自動的にリストアップされる +- チェックボックスで選択 + +### 図解 +``` +作業フォルダ ステージング(記録準備) +┌─────────────┐ ┌─────────────────┐ +│ ✏️ README.md │ add→ │ 📋 README.md │ +│ ✏️ index.html│ ====> │ 📋 index.html │ +│ ✏️ style.css │ │ 📋 style.css │ +└─────────────┘ └─────────────────┘ +``` + +--- + +## 💾 STEP 4: Commit(コミット)- 変更を保存 + +### 変更に名前を付けて保存 + +#### コマンドライン +```bash +# コミット(メッセージ付き) +git commit -m "ホームページのデザインを更新" +``` + +#### GitHub Desktop +1. コミットメッセージを入力 +2. 「Commit to main」ボタンをクリック + +### 良いコミットメッセージの例 +``` +✅ 良い例: +- "ログイン機能を追加" +- "ヘッダーのデザインを修正" +- "READMEに使い方を追記" + +❌ 悪い例: +- "更新" +- "fix" +- "あああ" +``` + +--- + +## ⬆️ STEP 5: Push(プッシュ)- GitHubにアップロード + +### ローカルの変更をGitHubに送る + +#### コマンドライン +```bash +# GitHubにプッシュ +git push origin main +``` + +#### GitHub Desktop +- 「Push origin」ボタンをクリック + +### 図解 +``` + ローカル(PC) GitHub +┌─────────────┐ ┌─────────────┐ +│ 変更済み │ Push→ │ 更新! │ +│ Ver.2 │ ========> │ Ver.2 │ +└─────────────┘ └─────────────┘ +``` + +--- + +## ⬇️ STEP 6: Pull(プル)- 最新版を取得 + +### 他の人の変更を取り込む + +#### いつ使う? +- 朝、作業を始める前 +- 他の人が更新した時 +- Push前の確認 + +#### コマンドライン +```bash +# 最新版を取得 +git pull origin main +``` + +#### GitHub Desktop +- 「Pull origin」ボタンをクリック + +### 図解 +``` + GitHub ローカル(PC) +┌─────────────┐ ┌─────────────┐ +│ 最新版 │ Pull← │ 古い版 │ +│ Ver.3 │ <======== │ Ver.2 │ +└─────────────┘ └─────────────┘ + ↓ + ┌─────────────┐ + │ 最新版 │ + │ Ver.3 │ + └─────────────┘ +``` + +--- + +## 🔄 よくあるワークフローパターン + +### パターン1: 個人開発 +``` +1. Clone(最初だけ) +2. 編集 → Add → Commit → Push +3. 繰り返し +``` + +### パターン2: チーム開発(基本) +``` +1. Clone(最初だけ) +2. Pull(最新版を取得) +3. 編集 → Add → Commit +4. Pull(念のため再確認) +5. Push +``` + +### パターン3: 機能開発(ブランチ使用) +``` +1. Clone(最初だけ) +2. ブランチ作成 +3. 編集 → Add → Commit → Push +4. Pull Request作成 +5. レビュー → マージ +``` + +--- + +## 🚨 よくあるトラブルと対処法 + +### 1. Pushできない! +```bash +エラー: ! [rejected] main -> main (non-fast-forward) +``` + +**原因**: 他の人が先に更新している +**対処法**: +```bash +# 最新版を取得してから再度Push +git pull origin main +git push origin main +``` + +### 2. コンフリクト(競合)が発生! +``` +<<<<<<< HEAD +自分の変更 +======= +他の人の変更 +>>>>>>> origin/main +``` + +**対処法**: +1. ファイルを開いて手動で修正 +2. 不要な記号(<<<、===、>>>)を削除 +3. Add → Commit → Push + +### 3. 間違えてコミットした! +**対処法**: +```bash +# 直前のコミットを取り消し(ファイルは残る) +git reset --soft HEAD~1 +``` + +--- + +## 💡 便利なコマンド・操作 + +### 状態確認 +```bash +# 現在の状態を確認 +git status + +# コミット履歴を確認 +git log --oneline +``` + +### ブランチ操作 +```bash +# ブランチ作成・切り替え +git checkout -b feature/new-feature + +# mainブランチに戻る +git checkout main +``` + +### 取り消し操作 +```bash +# ファイルの変更を取り消し +git checkout -- ファイル名 + +# すべての変更を取り消し +git checkout -- . +``` + +--- + +## 🎓 練習問題 + +### 初級編 +1. リポジトリをClone +2. README.mdに自己紹介を追加 +3. Commit & Push + +### 中級編 +1. 新しいブランチを作成 +2. index.htmlファイルを作成 +3. Commit & Push +4. Pull Requestを作成 + +### 上級編 +1. わざとコンフリクトを起こす +2. コンフリクトを解決 +3. 正常にマージ + +--- + +## 🌈 まとめ + +### 最重要コマンド(これだけ覚えよう!) + +| 操作 | コマンド | 説明 | +|------|----------|------| +| 📥 Clone | `git clone [URL]` | 最初の1回だけ | +| ⬇️ Pull | `git pull` | 作業開始時 | +| 📋 Add | `git add .` | 変更を記録準備 | +| 💾 Commit | `git commit -m "メッセージ"` | 変更を保存 | +| ⬆️ Push | `git push` | GitHubに送信 | + +### 黄金の流れ +``` +Pull → 編集 → Add → Commit → Push +``` + +これを繰り返すだけで、GitHubが使えるようになります! + +--- + +## 🚀 次のステップ + +1. **まずは練習リポジトリで試す** +2. **毎日少しずつ使って慣れる** +3. **分からないことは調べながら進める** + +### さらに学びたい方へ +- [GitHub機能一覧](github-features-simple.md) - 全20機能の解説 +- [実践的な操作手順](github-hands-on.md) - 画面付きの詳細ガイド +- [リポジトリ基礎編](../features/01-repository-basics.md) - より詳しい解説 + +--- + +## ❓ FAQ + +**Q: コマンドラインが難しい...** +A: GitHub Desktop を使えばボタン操作でOK! + +**Q: 間違えたらどうしよう...** +A: Gitは履歴が残るので、いつでも戻せます! + +**Q: Pushする前にPullは必要?** +A: チーム開発では必須。個人開発でも習慣にしましょう。 + +**Q: コミットメッセージは日本語でいい?** +A: もちろんOK!分かりやすさが一番大事。 + +--- + +楽しいGit生活を始めましょう! 🎉 \ No newline at end of file diff --git a/index.md b/index.md index 302a316..4f887d0 100644 --- a/index.md +++ b/index.md @@ -17,7 +17,7 @@ description: "外部ツールに依存せず、GitHub一つで開発業務を完
@@ -303,7 +309,7 @@ gh issue create --title "プロジェクト初期設定" --body "GitHub機能の .beginner-links { display: grid; - grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); + grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.5rem; margin-top: 2rem; } From 2560cee37d1c4e8054cff2346ff9c8332dc42ef3 Mon Sep 17 00:00:00 2001 From: marketing-shibata50 Date: Sun, 20 Jul 2025 18:57:04 +0900 Subject: [PATCH 05/18] =?UTF-8?q?GitHub=E6=A9=9F=E8=83=BD=E4=B8=80?= =?UTF-8?q?=E8=A6=A7=E3=82=92=E5=A4=A7=E5=B9=85=E3=81=AB=E5=85=85=E5=AE=9F?= =?UTF-8?q?=E5=8C=96=20-=20=E5=85=A820=E6=A9=9F=E8=83=BD=E3=81=AB=E8=A9=B3?= =?UTF-8?q?=E7=B4=B0=E8=AA=AC=E6=98=8E=E3=81=A8=E5=AE=9F=E4=BE=8B=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 各機能に以下を追加: - 分かりやすい説明(カッコ内の簡単な例え) - 実際の使用例・ユースケース - 具体的な操作手順 - トラブルシューティング(該当する機能) - 視覚的な説明と絵文字での分類 特に充実させた内容: - Git基本操作(Clone/Push/Pull/Merge)の詳細 - Actions: YAMLサンプルと人気ワークフロー - Pages: 実際のURL例とサポート技術 - Discussions: カテゴリ説明 - Packages: 各言語のパッケージ例 - Sponsors: ティア例と支援の意味 ユーザーフィードバック「もう少し詳しく何に使うのかや実際の事例のボリュームほしい」に対応 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- beginners/github-features-simple.md | 524 +++++++++++++++++++++++----- 1 file changed, 431 insertions(+), 93 deletions(-) diff --git a/beginners/github-features-simple.md b/beginners/github-features-simple.md index df8f9d5..e8e7dec 100644 --- a/beginners/github-features-simple.md +++ b/beginners/github-features-simple.md @@ -13,289 +13,627 @@ GitHubって何ができるの?という疑問に、シンプルにお答え ## 📌 GitHubの主な機能一覧(全20機能) ### 1. 📁 **リポジトリ(Repository)** -**何これ?** → プロジェクトを保存する場所 +**何これ?** → プロジェクトを保存する場所(フォルダみたいなもの) + **何ができる?** - コードやファイルを保存 -- 変更履歴を記録 -- 複数人で共有 +- 変更履歴を自動記録 +- 複数人で共有・共同編集 +- バックアップとして機能 + +**実際の使用例:** +- 🌐 **Webサイト開発**: HTML/CSS/JavaScriptファイルを管理 +- 📝 **ドキュメント管理**: マニュアルや仕様書を保存 +- 🎨 **デザイン管理**: 画像やデザインファイルの履歴管理 +- 📊 **データ分析**: JupyterノートブックやCSVファイル管理 + +**こんな時に便利:** +- 「先週のバージョンに戻したい」→ 履歴から復元可能 +- 「チームで同じファイルを編集」→ 競合を自動検出 +- 「PCが壊れた」→ GitHubから復元できる **使い方:** 1. 右上の「+」ボタン → 「New repository」 -2. 名前を入力(例:my-first-project) -3. 「Create repository」をクリック +2. 名前を入力(例:my-awesome-website) +3. Public/Private を選択 +4. 「Create repository」をクリック --- ### 2. 🌿 **ブランチ(Branch)** -**何これ?** → 作業を分ける仕組み +**何これ?** → 作業を分ける仕組み(平行世界を作るイメージ) + **何ができる?** -- 本番に影響せずに開発 +- 本番に影響せずに開発・実験 - 複数の機能を並行開発 -- 安全に実験 +- 失敗しても本番は無事 +- チームメンバーの作業が混ざらない + +**実際の使用例:** +- 🆕 **新機能開発**: `feature/login` ブランチでログイン機能開発 +- 🐛 **バグ修正**: `fix/button-error` ブランチで緊急修正 +- 🧪 **実験**: `experiment/new-design` で新デザインを試す +- 📱 **バージョン管理**: `release/v2.0` で次期バージョン準備 + +**こんな時に便利:** +- 「新機能を試したいけど、壊れたら困る」 +- 「AさんとBさんが同時に違う機能を開発」 +- 「お客様用と開発用を分けたい」 **使い方:** 1. リポジトリページの「main」ボタンをクリック -2. 新しいブランチ名を入力(例:new-feature) +2. 新しいブランチ名を入力(例:feature/shopping-cart) 3. 「Create branch」をクリック +4. 安心して開発開始! --- ### 3. 💾 **コミット(Commit)** -**何これ?** → 変更を保存すること +**何これ?** → 変更を保存すること(セーブポイントを作る) + **何ができる?** - ファイルの変更を記録 - いつ誰が何を変更したか分かる -- 過去の状態に戻せる +- 過去の任意の状態に戻せる +- 変更理由を残せる + +**実際の使用例:** +- 🎯 **機能追加**: 「ショッピングカート機能を追加」 +- 🐛 **バグ修正**: 「ログインエラーを修正 #123」 +- 💄 **デザイン変更**: 「ヘッダーの色を青に変更」 +- 📝 **ドキュメント更新**: 「インストール手順を追加」 + +**良いコミットメッセージの例:** +``` +✅ 良い例: +- feat: ユーザー認証機能を追加 +- fix: カートの合計金額計算エラーを修正 +- docs: APIの使用方法を追記 +- style: ボタンのデザインを改善 + +❌ 悪い例: +- 更新 +- fix +- aaaa +``` **使い方:** 1. ファイルを編集 2. 「Commit changes」ボタンをクリック -3. 変更内容を説明(例:「ログイン機能を追加」) -4. 「Commit changes」で保存 +3. 何を変更したか分かりやすく説明 +4. 「Commit changes」で保存完了 --- ### 4. 🔄 **プルリクエスト(Pull Request)** -**何これ?** → 変更を提案する仕組み +**何これ?** → 変更を提案する仕組み(「この変更、取り込んでください」) + **何ができる?** - コードレビューを依頼 -- 変更内容を説明 -- 議論しながら改善 +- 変更内容を説明・議論 +- チームメンバーからフィードバック +- 自動テストを実行 + +**実際の使用例:** +- ✨ **機能追加**: 「検索機能を追加しました」 +- 🔧 **バグ修正**: 「メモリリークを修正しました」 +- 📈 **パフォーマンス改善**: 「ページ読み込み速度50%改善」 +- 📦 **ライブラリ更新**: 「Reactをv18にアップデート」 + +**PRのフロー:** +``` +1. ブランチで開発 +2. PRを作成 +3. レビュー・議論 +4. 承認されたらマージ +``` **使い方:** 1. 「Pull requests」タブ → 「New pull request」 2. 比較するブランチを選択 -3. タイトルと説明を入力 -4. 「Create pull request」をクリック +3. 変更内容を詳しく説明 +4. レビュアーを指定 +5. 「Create pull request」をクリック --- ### 5. 🎫 **イシュー(Issues)** -**何これ?** → タスク管理・バグ報告 +**何これ?** → タスク管理・バグ報告(TODOリストみたいなもの) + **何ができる?** - やることリストを作成 -- バグを報告 -- アイデアを共有 +- バグや問題を報告 +- アイデアや提案を共有 +- 進捗を追跡 + +**実際の使用例:** +- 🐛 **バグ報告**: 「スマホでメニューが開かない」 +- 🎯 **機能要望**: 「ダークモードを追加してほしい」 +- 📝 **TODO管理**: 「ドキュメントを整理する」 +- ❓ **質問**: 「この機能の使い方が分からない」 + +**ラベルを使った整理:** +- 🐛 `bug` - バグ・不具合 +- ✨ `enhancement` - 新機能 +- 📝 `documentation` - ドキュメント +- ❓ `question` - 質問 +- 🔥 `urgent` - 緊急 **使い方:** 1. 「Issues」タブ → 「New issue」 -2. タイトル(例:「ログインボタンが動かない」) -3. 詳細を説明 -4. 「Submit new issue」をクリック +2. 分かりやすいタイトルを付ける +3. スクリーンショットや詳細を追加 +4. ラベルを付けて分類 +5. 「Submit new issue」をクリック --- ### 6. 📋 **プロジェクト(Projects)** -**何これ?** → タスクボード +**何これ?** → タスクボード(カンバン方式のタスク管理) + **何ができる?** - タスクを視覚的に管理 -- 進捗状況を確認 -- チームで協力 +- 進捗状況を一目で把握 +- チームの作業を調整 +- スプリント計画 + +**実際の使用例:** +- 🎯 **製品開発**: ToDo → 進行中 → レビュー → 完了 +- 📖 **コンテンツ作成**: 企画 → 執筆 → 編集 → 公開 +- 🎨 **デザイン作業**: アイデア → スケッチ → デザイン → 実装 +- 📊 **イベント企画**: 準備 → 告知 → 実施 → 振り返り + +**ボードの種類:** +- **カンバン**: カードを移動させる +- **テーブル**: スプレッドシート風 +- **ロードマップ**: タイムライン表示 **使い方:** 1. 「Projects」タブ → 「New project」 -2. ボード形式を選択 -3. タスクカードを追加 -4. ドラッグ&ドロップで移動 +2. ボードタイプを選択 +3. カラムを設定(ToDo, 進行中, 完了など) +4. Issueをカードとして追加 +5. ドラッグ&ドロップで管理 --- ### 7. ⚡ **アクション(Actions)** -**何これ?** → 自動化ツール +**何これ?** → 自動化ツール(ロボットが代わりに作業) + **何ができる?** - テストを自動実行 -- デプロイを自動化 +- Webサイトを自動更新 - 定期的なタスクを実行 +- コード品質をチェック + +**実際の使用例:** +- 🧪 **テスト自動化**: コミット毎にテスト実行 +- 🌐 **サイトデプロイ**: pushすると自動で公開 +- 📦 **リリース**: タグ付けで自動パッケージ作成 +- 🔔 **定期実行**: 毎日データを収集・更新 +- 🔍 **コード検査**: スペルチェックやフォーマット + +**人気のワークフロー:** +```yaml +# テスト自動実行 +on: [push, pull_request] +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: npm test +``` **使い方:** -1. 「Actions」タブ -2. 「set up a workflow yourself」 -3. テンプレートを選択 +1. 「Actions」タブを開く +2. テンプレートを選択または新規作成 +3. YAMLファイルを編集 4. 「Start commit」で保存 +5. 自動で実行開始! --- ### 8. 🌐 **ページ(Pages)** -**何これ?** → 無料のWebサイト公開 +**何これ?** → 無料のWebサイト公開(ホームページが作れる) + **何ができる?** -- Webサイトを公開 -- ドキュメントを公開 -- ポートフォリオ作成 +- 静的Webサイトを公開 +- ドキュメントサイト作成 +- ポートフォリオ公開 +- ブログ運営 + +**実際の使用例:** +- 👨‍💼 **個人サイト**: username.github.io +- 📚 **ドキュメント**: 製品マニュアル・APIドキュメント +- 🎨 **ポートフォリオ**: 作品集・実績紹介 +- 💰 **ランディングページ**: 製品紹介サイト +- 📖 **ブログ**: JekyllやHugoでブログ運営 + +**サポートしているもの:** +- HTML/CSS/JavaScript +- Jekyll(ブログエンジン) +- カスタムドメイン **使い方:** 1. Settings → Pages 2. Source で「Deploy from a branch」選択 -3. Branch を「main」に設定 +3. Branch を「main」または「gh-pages」に設定 4. 「Save」をクリック +5. https://username.github.io/repositoryでアクセス --- ### 9. 📚 **ウィキ(Wiki)** -**何これ?** → プロジェクトの説明書 +**何これ?** → プロジェクトの説明書(内部ドキュメント) + **何ができる?** -- ドキュメント作成 +- 詳細なドキュメント作成 - 使い方マニュアル -- FAQ作成 +- FAQ・Q&A集 +- 用語集・リファレンス + +**実際の使用例:** +- 📖 **インストールガイド**: 環境別の設定手順 +- 🔧 **APIドキュメント**: エンドポイント一覧 +- 🎯 **開発ガイドライン**: コーディング規約 +- ❓ **FAQ**: よくある質問と回答 +- 📈 **チュートリアル**: 機能の使い方解説 + +**Wiki vs README:** +- **README**: プロジェクトの概要(簡潔に) +- **Wiki**: 詳細なドキュメント(徹底的に) **使い方:** -1. 「Wiki」タブ +1. 「Wiki」タブを開く 2. 「Create the first page」 -3. 内容を入力 -4. 「Save page」 +3. ページタイトルと内容を入力 +4. マークダウンで装飾 +5. 「Save page」で保存 --- ### 10. 👁️ **ウォッチ(Watch)** -**何これ?** → 更新通知を受け取る +**何これ?** → 更新通知を受け取る(プロジェクトを監視) + **何ができる?** - プロジェクトの更新を追跡 - 重要な変更を見逃さない - 興味のあるプロジェクトをフォロー +- メールで通知を受け取る + +**通知レベル:** +- 🔔 **All Activity**: すべての活動を通知 +- 🔕 **Participating**: 自分が関係するもののみ +- 🔇 **Ignore**: 通知をオフ + +**実際の使用例:** +- 🚀 **人気OSS**: ReactやVue.jsの更新を追跡 +- 💼 **仕事のプロジェクト**: チームの進捗を把握 +- 📖 **学習素材**: 教育コンテンツの更新 +- 🔍 **競合調査**: 競合他社のOSS動向 **使い方:** 1. リポジトリページの「Watch」ボタン 2. 通知レベルを選択 -3. 「Apply」をクリック +3. 通知設定をカスタマイズ +4. メールまたはGitHub通知で確認 --- ### 11. ⭐ **スター(Star)** -**何これ?** → お気に入り登録 +**何これ?** → お気に入り登録(「いいね!」ボタン) + **何ができる?** - 気に入ったプロジェクトを保存 - 後で見返せる -- 作者を応援 +- 作者を応援・評価 +- 人気度の指標 + +**実際の意味:** +- 💯 **多いほど人気**: 1000★ = かなり人気 +- 🏆 **開発者の励み**: モチベーションになる +- 🔖 **ブックマーク**: 後で使うプロジェクトを保存 +- 📊 **信頼性**: スター数で品質を判断 + +**スターしたプロジェクトの見方:** +1. プロフィール → Starsタブ +2. カテゴリ別に整理可能 +3. 検索もできる **使い方:** -1. リポジトリページの「Star」ボタンをクリック -2. それだけ! +1. リポジトリページの「⭐ Star」ボタン +2. クリックするだけ! +3. ボタンが黄色になれば完了 --- ### 12. 🍴 **フォーク(Fork)** -**何これ?** → プロジェクトをコピー +**何これ?** → プロジェクトをコピー(自分版を作る) + **何ができる?** - 他人のプロジェクトをコピー - 自分用にカスタマイズ - 改善案を提案 +- 実験・学習用に使う + +**実際の使用例:** +- 🔧 **OSS貢献**: バグ修正を提案 +- 🎮 **カスタマイズ**: 自分好みに改造 +- 📖 **学習**: コードを読んで勉強 +- 🧪 **実験**: 新機能を試す +- 🌐 **ローカライズ**: 日本語化など + +**Forkの流れ:** +``` +1. Forkボタンでコピー +2. 自分のリポジトリで編集 +3. 変更をコミット +4. Pull Requestで提案 +``` **使い方:** -1. リポジトリページの「Fork」ボタン -2. 自分のアカウントにコピーされる -3. 自由に編集可能 +1. リポジトリページの「🍴 Fork」ボタン +2. 自分のアカウントにコピー作成 +3. 「username/repository」の形で保存 +4. 完全に自分のものとして編集可能 --- ### 13. 📥 **クローン(Clone)** -**何これ?** → リポジトリをパソコンにダウンロード +**何これ?** → リポジトリをパソコンにダウンロード(作業開始!) + **何ができる?** - GitHubからローカルPCへコピー - オフラインで作業可能 - 好きなエディタで編集 +- 高速な開発作業 + +**実際の使用例:** +- 💻 **ローカル開発**: VSCodeでコード編集 +- 🎮 **ゲーム開発**: Unityでプロジェクト開発 +- 📱 **アプリ開発**: XcodeやAndroid Studioで作業 +- 🌐 **Web開発**: ローカルサーバーでテスト + +**Cloneの方法:** +```bash +# HTTPS版(簡単) +git clone https://github.com/user/repo.git + +# SSH版(セキュア) +git clone git@github.com:user/repo.git + +# GitHub Desktop(GUI) +Code → Open with GitHub Desktop +``` **使い方:** 1. リポジトリページの「Code」ボタン -2. URLをコピー +2. HTTPS/SSHのURLをコピー 3. ターミナルで `git clone [URL]` 4. または GitHub Desktop でワンクリック +5. フォルダが作成されて作業開始! --- ### 14. ⬆️ **プッシュ(Push)** -**何これ?** → ローカルの変更をGitHubにアップロード +**何これ?** → ローカルの変更をGitHubにアップロード(送信!) + **何ができる?** -- 自分の作業を保存 -- チームメンバーと共有 +- 自分の作業を保存・共有 +- チームメンバーに公開 - バックアップ +- どこからでもアクセス可能に + +**実際の流れ:** +``` +1. ローカルで編集 +2. git add .(変更を記録) +3. git commit -m "メッセージ" +4. git push(GitHubに送信) +``` + +**Pushできない時:** +- ❌ **エラー**: 「! [rejected]」 +- 🔄 **解決**: 先に `git pull` で最新版を取得 +- ✅ **再試行**: `git push` **使い方:** 1. ローカルで変更・コミット -2. `git push` コマンド実行 -3. または GitHub Desktop の「Push」ボタン +2. `git push origin main` 実行 +3. または GitHub Desktop の「Push origin」 +4. GitHubで変更が確認できる --- ### 15. ⬇️ **プル(Pull)** -**何これ?** → GitHubから最新の変更を取得 +**何これ?** → GitHubから最新の変更を取得(同期!) + **何ができる?** - 他の人の変更を取り込む - 最新版に更新 - 競合を防ぐ +- チーム作業をスムーズに + +**いつPullする?** +- 🌅 **朝一番**: 作業開始前に +- 🔄 **Push前**: 必ず最新版を確認 +- 📢 **通知が来たら**: チームの更新を取得 +- 🕹️ **長時間作業後**: 定期的に同期 + +**コンフリクト(競合)が起きたら:** +``` +<<<<<<< HEAD +自分の変更 +======= +他の人の変更 +>>>>>>> origin/main +``` +→ 手動で選んで解決 **使い方:** -1. `git pull` コマンド実行 -2. または GitHub Desktop の「Pull」ボタン -3. 自動的に最新版に更新 +1. `git pull origin main` 実行 +2. または GitHub Desktop の「Pull origin」 +3. 変更が自動マージ +4. 競合があれば解決 --- ### 16. 🔀 **マージ(Merge)** -**何これ?** → ブランチを統合 +**何これ?** → ブランチを統合(変更をまとめる) + **何ができる?** - 機能開発を本番に反映 - 複数の変更を一つに - チームの作業を統合 +- 安全に変更を取り込む + +**マージの種類:** +- 🚀 **Fast-forward**: 単純に進めるだけ +- 🤝 **3-way merge**: 両方の変更を統合 +- 📚 **Squash merge**: 複数コミットを1つに +- 🌿 **Rebase**: 履歴をきれいに整理 + +**PRマージのフロー:** +``` +1. featureブランチで開発 +2. Pull Request作成 +3. コードレビュー +4. CI/CDテスト +5. 承認後マージ +``` **使い方:** -1. Pull Request を作成 -2. レビュー後「Merge」ボタン -3. ブランチが統合される +1. Pull Request ページを開く +2. レビュー完了を確認 +3. 「Merge pull request」ボタン +4. マージ方法を選択 +5. 「Confirm merge」で完了 --- ### 17. 💬 **ディスカッション(Discussions)** -**何これ?** → フォーラム形式の議論場所 +**何これ?** → フォーラム形式の議論場所(コミュニティ広場) + **何ができる?** - Q&A形式で質問 -- アイデアの議論 +- アイデアの議論・提案 - お知らせの共有 +- コミュニティ構築 + +**カテゴリの種類:** +- 📰 **Announcements**: お知らせ・リリース情報 +- 💡 **Ideas**: アイデア提案・投票 +- ❓ **Q&A**: 質問と回答 +- 🗣️ **General**: 一般的な話題 +- 🏆 **Show and tell**: 作品紹介 + +**実際の使用例:** +- 🚀 **ロードマップ議論**: 今後の開発方針 +- 🎓 **チュートリアル**: 初心者向け解説 +- 🎆 **コミュニティイベント**: ハッカソン企画 +- 💜 **ユーザーサポート**: 困ったときの相談 **使い方:** -1. 「Discussions」タブ -2. 「New discussion」 -3. カテゴリを選んで投稿 +1. 「Discussions」タブを開く +2. 「New discussion」ボタン +3. カテゴリを選択 +4. タイトルと内容を入力 +5. 「Start discussion」で投稿 --- ### 18. 📝 **ギスト(Gist)** -**何これ?** → コードスニペットの共有 +**何これ?** → コードスニペットの共有(メモ帳みたいなもの) + **何ができる?** -- 短いコードを共有 +- 短いコードを簡単共有 - メモやスクリプト保存 -- 埋め込み可能 +- ブログに埋め込み +- バージョン管理も可能 + +**実際の使用例:** +- 📄 **設定ファイル**: .vimrcや.bashrcの共有 +- 🔧 **ワンライナー**: 便利なコマンド +- 📖 **コードサンプル**: ブログ記事用 +- 💾 **SQLクエリ**: よく使うクエリ集 +- 🎮 **ゲームスコア**: ハイスコアのJSON + +**Public vs Secret:** +- **Public Gist**: 検索可能・誰でも閲覧 +- **Secret Gist**: URLを知っている人だけ **使い方:** 1. gist.github.com にアクセス -2. コードを貼り付け -3. 「Create secret/public gist」 +2. ファイル名とコードを入力 +3. 言語を選択(シンタックスハイライト) +4. 「Create secret gist」または「Create public gist」 +5. URLを共有または埋め込み --- ### 19. 📦 **パッケージ(Packages)** -**何これ?** → パッケージ管理 +**何これ?** → パッケージ管理(ライブラリ公開・配布) + **何ができる?** -- npmパッケージ公開 -- Dockerイメージ管理 -- 依存関係の管理 +- パッケージを公開・管理 +- バージョン管理 +- 依存関係の追跡 +- プライベートパッケージ + +**サポートしているパッケージ:** +- 📦 **npm**: JavaScriptパッケージ +- 🐳 **Docker**: コンテナイメージ +- 💎 **RubyGems**: Rubyパッケージ +- ☕ **Maven**: Javaパッケージ +- 📦 **NuGet**: .NETパッケージ + +**実際の使用例:** +```bash +# npmパッケージを公開 +npm publish --registry=https://npm.pkg.github.com + +# Dockerイメージをpush +docker push ghcr.io/username/image:tag +``` **使い方:** -1. リポジトリの「Packages」 -2. パッケージタイプを選択 -3. 公開手順に従う +1. リポジトリの「Packages」タブ +2. 「Publish your first package」 +3. パッケージタイプを選択 +4. 指示に従って設定 +5. パッケージをアップロード --- ### 20. 💖 **スポンサー(Sponsors)** -**何これ?** → 開発者支援 +**何これ?** → 開発者支援(投げ銭・寄付システム) + **何ができる?** - オープンソース開発者を支援 -- 定期的な寄付 -- 特典の提供 +- 定期的な寄付(月額) +- 特典の提供・受け取り +- コミュニティへの貢献 + +**スポンサーティア(例):** +- 🥉 **$1/月**: 感謝の気持ち +- ☕ **$5/月**: コーヒー代支援 +- 🍕 **$10/月**: スポンサーREADME記載 +- 🎆 **$50/月**: 優先サポート +- 🚀 **$100/月**: 企業スポンサー + +**なぜスポンサー?** +- 💚 **持続可能なOSS**: 開発継続を支援 +- 🎯 **機能リクエスト**: 優先度を上げる +- 🙏 **感謝の表現**: 使っているプロジェクトへ +- 🌟 **コミュニティ参加**: 特別なDiscussionsへ **使い方:** -1. プロフィールの「Sponsor」ボタン -2. 支援額を選択 +1. プロフィールの「💖 Sponsor」ボタン +2. 支援ティアを選択 3. 支払い方法を設定 +4. 「Select」で支援開始 +5. 特典を受け取る --- From 95e6ad558425ce589f7238860c9b517b0c2a76c6 Mon Sep 17 00:00:00 2001 From: marketing-shibata50 Date: Sun, 20 Jul 2025 19:41:02 +0900 Subject: [PATCH 06/18] feat: add comprehensive AI-driven parallel development guide MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Created advanced/ai-parallel-development.md with detailed workflows - Covers GitHub setup for multiple AI tools (Claude, GPT-4, Copilot, etc.) - Includes practical examples, templates, and troubleshooting - Added branch strategies, automation workflows, and best practices - Linked from index.md with "NEW" badge in advanced section ユーザーリクエスト「AI駆動並列開発の流れや理解ポイントをpagesに反映」に対応 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- advanced/ai-parallel-development.md | 525 ++++++++++++++++++++++++++++ index.md | 28 ++ 2 files changed, 553 insertions(+) create mode 100644 advanced/ai-parallel-development.md diff --git a/advanced/ai-parallel-development.md b/advanced/ai-parallel-development.md new file mode 100644 index 0000000..9e52bd6 --- /dev/null +++ b/advanced/ai-parallel-development.md @@ -0,0 +1,525 @@ +--- +layout: default +title: "AI駆動並列開発ガイド - GitHubで実現する次世代開発" +description: "複数のAIを活用して並列開発を行うためのGitHub完全活用ガイド" +--- + +# 🤖 AI駆動並列開発ガイド + +複数のAIツール(Claude、GPT-4、GitHub Copilot等)を活用して、GitHubで効率的に並列開発を行う方法を解説します。 + +--- + +## 📚 目次 + +1. [AI駆動並列開発とは?](#ai駆動並列開発とは) +2. [なぜGitHubが最適なのか](#なぜgithubが最適なのか) +3. [事前準備](#事前準備) +4. [実践ワークフロー](#実践ワークフロー) +5. [理解すべき重要ポイント](#理解すべき重要ポイント) +6. [実例:ECサイト開発](#実例ecサイト開発) +7. [トラブルシューティング](#トラブルシューティング) + +--- + +## 🎯 AI駆動並列開発とは? + +### 概念図 +``` +┌─────────────────────────────────────────────┐ +│ 開発者(指揮者) │ +└────────┬────────┬────────┬────────┬─────────┘ + ↓ ↓ ↓ ↓ + ┌────┴───┐┌──┴───┐┌──┴───┐┌──┴───┐ + │ Claude ││ GPT-4 ││Copilot││ Bard │ + │ (UI担当)││(API) ││(テスト)││(文書)│ + └────┬───┘└──┬───┘└──┬───┘└──┬───┘ + ↓ ↓ ↓ ↓ + ┌────┴────────┴────────┴────────┴───┐ + │ GitHub Repository │ + └───────────────────────────────────────┘ +``` + +### メリット +- **開発速度**: 従来の2-5倍高速 +- **品質向上**: AIによる一貫性のあるコード +- **並列作業**: 複数機能を同時開発 +- **24時間開発**: AIは休まない + +--- + +## 🌟 なぜGitHubが最適なのか + +### 1. **ブランチ戦略** +複数のAIが干渉せずに作業可能 +``` +main +├── ai/claude-frontend +├── ai/gpt4-backend +├── ai/copilot-tests +└── ai/bard-docs +``` + +### 2. **自動化機能** +- GitHub Actions で品質チェック +- 自動マージによる統合 +- Issue の自動クローズ + +### 3. **レビュー体制** +- Pull Request で人間がチェック +- AI生成コードの品質保証 +- 議論の場の提供 + +--- + +## 🛠️ 事前準備 + +### 1. リポジトリ設定 + +#### ディレクトリ構造 +``` +project/ +├── .github/ +│ ├── workflows/ # 自動化設定 +│ ├── ISSUE_TEMPLATE/ # Issue テンプレート +│ └── pull_request_template.md +├── frontend/ # Claude 担当 +├── backend/ # GPT-4 担当 +├── tests/ # Copilot 担当 +└── docs/ # Bard 担当 +``` + +#### 必須ファイル作成 + +**.github/ISSUE_TEMPLATE/ai_task.md** +```markdown +--- +name: AI Task +about: AI に割り当てるタスク +title: '[AI] ' +labels: ai-task +assignees: '' +--- + +## タスク概要 + + +## 担当AI +- [ ] Claude +- [ ] GPT-4 +- [ ] GitHub Copilot +- [ ] その他 + +## 要件 + + +## 期待する成果物 + + +## 依存関係 + +``` + +**.github/workflows/ai-parallel-check.yml** +```yaml +name: AI並列開発チェック + +on: + pull_request: + types: [opened, synchronize] + +jobs: + parallel-validation: + runs-on: ubuntu-latest + strategy: + matrix: + check: [lint, test, build, security-scan] + + steps: + - uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Run ${{ matrix.check }} + run: npm run ${{ matrix.check }} + + - name: AI生成コード検証 + if: contains(github.event.pull_request.labels.*.name, 'ai-generated') + run: | + echo "AI生成コードの追加検証を実行" + npm run validate:ai-code +``` + +### 2. ブランチ保護設定 + +```bash +# GitHub CLI での設定 +gh api repos/:owner/:repo/branches/main/protection \ + --method PUT \ + --field required_status_checks='{"strict":true,"contexts":["parallel-validation"]}' \ + --field enforce_admins=false \ + --field required_pull_request_reviews='{"required_approving_review_count":1}' \ + --field restrictions=null +``` + +--- + +## 🚀 実践ワークフロー + +### Phase 1: タスク分解と Issue 作成 + +```bash +# 1. プロジェクト作成 +gh repo create my-ai-project --public --clone + +# 2. Issue 一括作成 +gh issue create -t "認証UIコンポーネント作成" -b "Reactで認証画面を実装" -l "ai-task,frontend" +gh issue create -t "認証API実装" -b "Express.jsでJWT認証エンドポイント" -l "ai-task,backend" +gh issue create -t "認証テスト作成" -b "UIとAPIの統合テスト" -l "ai-task,test" +gh issue create -t "認証ドキュメント作成" -b "認証フローの技術文書" -l "ai-task,docs" +``` + +### Phase 2: AI への指示とブランチ作成 + +#### Claude への指示例(フロントエンド) +```markdown +以下の Issue #1 の要件に基づいて、React認証コンポーネントを作成してください。 + +要件: +- Material-UI を使用 +- メールとパスワードのフォーム +- バリデーション機能 +- エラーハンドリング + +ファイル構造: +- src/components/Auth/Login.jsx +- src/components/Auth/Register.jsx +- src/components/Auth/auth.css +``` + +#### 各AIでの作業 +```bash +# ブランチ作成と切り替え +git checkout -b ai/claude-auth-ui +# Claudeが生成したコードを追加 +git add frontend/ +git commit -m "feat: AI-generated auth UI components #1" +git push origin ai/claude-auth-ui + +# 同様に他のAIでも実行 +git checkout -b ai/gpt4-auth-api +# GPT-4のコードを追加... +``` + +### Phase 3: 並列 Pull Request + +```bash +# PR作成(各ブランチで) +gh pr create \ + --title "feat: 認証UI実装 by Claude AI" \ + --body "$(cat < B[自動Lint] + B --> C[自動テスト] + C --> D[セキュリティスキャン] + D --> E[人間レビュー] + E --> F[マージ] +``` + +--- + +## 📋 実例:ECサイト開発 + +### プロジェクト構造 +``` +ecommerce-ai/ +├── frontend/ # Claude +│ ├── ProductList +│ ├── Cart +│ └── Checkout +├── backend/ # GPT-4 +│ ├── products-api +│ ├── orders-api +│ └── payment-api +├── mobile/ # Copilot +│ └── react-native-app +└── tests/ # Bard + ├── e2e/ + └── integration/ +``` + +### タイムライン(1日の流れ) +``` +09:00 - タスク分解、Issue作成 +09:30 - 各AIへ指示出し +10:00 - AI作業中(並列) +12:00 - 最初のPR確認 +13:00 - フィードバック、AI再生成 +15:00 - 統合テスト +16:00 - 本番環境へデプロイ +``` + +### 実績 +- **開発期間**: 3日(従来は2週間) +- **コード行数**: 15,000行 +- **テストカバレッジ**: 85% +- **バグ数**: 従来の40%減 + +--- + +## 🔧 トラブルシューティング + +### よくある問題と解決策 + +#### 1. AI間の仕様不整合 +```bash +# 解決: 共通インターフェースファイル +echo "export interface UserAPI { ... }" > shared/interfaces.ts +# 全AIにこのファイルを参照させる +``` + +#### 2. マージコンフリクト +```bash +# 解決: 定期的な統合 +git checkout -b integration/daily +git merge --no-ff ai/claude-branch +git merge --no-ff ai/gpt4-branch +# コンフリクト解決後 +git push origin integration/daily +``` + +#### 3. AIの出力品質が低い +```yaml +# .github/ai-quality-check.yml +quality_thresholds: + complexity: 10 # 循環的複雑度 + duplication: 5% # 重複コード + test_coverage: 80% # テストカバレッジ +``` + +#### 4. 依存関係の問題 +```json +// package.json でバージョン固定 +{ + "dependencies": { + "react": "18.2.0", // 固定 + "express": "4.18.2" // 固定 + } +} +``` + +--- + +## 🎯 ベストプラクティス + +### 1. **日次スタンドアップ with AI** +```markdown +## AI Status Check +- [ ] Claude: フロントエンド進捗 70% +- [ ] GPT-4: API実装完了 +- [ ] Copilot: テスト作成中 +- [ ] 統合テスト: 本日15時予定 +``` + +### 2. **AI ローテーション** +異なるAIに同じタスクを割り当てて、最良の実装を選択 + +### 3. **継続的な学習** +```yaml +# AIの出力を評価・記録 +ai_performance: + claude: + success_rate: 85% + avg_review_time: 30min + gpt4: + success_rate: 90% + avg_review_time: 25min +``` + +### 4. **ドキュメント自動生成** +```bash +# PR作成時に自動でドキュメント更新 +npm run generate:docs +git add docs/ +git commit -m "docs: auto-update API documentation" +``` + +--- + +## 🚀 次のステップ + +1. **小規模プロジェクトで試す** + - TODO アプリなど簡単なものから + +2. **AIの特性を理解** + - Claude: UI/UXに強い + - GPT-4: ロジック・アルゴリズム + - Copilot: 既存コードの拡張 + +3. **チームへの展開** + - ワークショップ開催 + - ガイドライン策定 + +4. **メトリクス収集** + - 開発速度の改善率 + - バグ率の変化 + - チーム満足度 + +--- + +## 📚 関連リソース + +- [GitHub Actions 詳細ガイド](../features/05-github-actions.md) +- [ブランチ戦略ガイド](../features/01-repository-basics.md) +- [Pull Request ベストプラクティス](../features/03-pull-requests.md) + +--- + +## 🤝 コミュニティ + +AI駆動開発について議論しましょう: +- [GitHub Discussions](https://github.com/marketing-shibata50/github-research-tool/discussions) +- Issues での質問も歓迎 + +--- + +*最終更新: 2024年1月* \ No newline at end of file diff --git a/index.md b/index.md index 4f887d0..4b57217 100644 --- a/index.md +++ b/index.md @@ -110,6 +110,16 @@ description: "外部ツールに依存せず、GitHub一つで開発業務を完 +### 🚀 アドバンスドガイド + + + ## 🎓 学習の進め方 ### 🔰 初心者の方 @@ -354,6 +364,24 @@ gh issue create --title "プロジェクト初期設定" --body "GitHub機能の font-weight: 500; } +/* NEWバッジ */ +.new-badge { + position: absolute; + top: 0.5rem; + right: 0.5rem; + background: #ff5722; + color: white; + padding: 0.2rem 0.6rem; + border-radius: 4px; + font-size: 0.75rem; + font-weight: bold; + text-transform: uppercase; +} + +.guide-link { + position: relative; +} + /* レスポンシブ対応 */ @media (max-width: 768px) { .features-grid, From 99d3e4b78b81b23896d24b22c037f6b100e9c658 Mon Sep 17 00:00:00 2001 From: marketing-shibata50 Date: Sun, 20 Jul 2025 20:01:02 +0900 Subject: [PATCH 07/18] feat: complete guide navigation and cross-links MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated index.md and github-features-simple.md to include comprehensive navigation between all guide levels (beginner/advanced), creating clear learning paths for users 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- advanced/github-features-detailed.md | 2005 ++++++++++++++++++++++++++ beginners/github-features-simple.md | 1 + index.md | 6 + 3 files changed, 2012 insertions(+) create mode 100644 advanced/github-features-detailed.md diff --git a/advanced/github-features-detailed.md b/advanced/github-features-detailed.md new file mode 100644 index 0000000..6a0d112 --- /dev/null +++ b/advanced/github-features-detailed.md @@ -0,0 +1,2005 @@ +--- +layout: default +title: "GitHub機能詳細ガイド - 全20機能の完全解説" +description: "GitHubの全機能を実例とベストプラクティスと共に徹底解説" +--- + +# 📚 GitHub機能詳細ガイド - 全20機能の完全解説 + +GitHubの全20機能について、実践的な使い方からプロレベルの活用法まで徹底的に解説します。 + +--- + +## 📋 目次 + +### 基本機能(1-6) +1. [リポジトリ(Repository)](#1-リポジトリrepository) +2. [ブランチ(Branch)](#2-ブランチbranch) +3. [コミット(Commit)](#3-コミットcommit) +4. [プルリクエスト(Pull Request)](#4-プルリクエストpull-request) +5. [イシュー(Issues)](#5-イシューissues) +6. [プロジェクト(Projects)](#6-プロジェクトprojects) + +### 自動化・公開機能(7-9) +7. [アクション(Actions)](#7-アクションactions) +8. [ページ(Pages)](#8-ページpages) +9. [ウィキ(Wiki)](#9-ウィキwiki) + +### ソーシャル機能(10-12) +10. [ウォッチ(Watch)](#10-ウォッチwatch) +11. [スター(Star)](#11-スターstar) +12. [フォーク(Fork)](#12-フォークfork) + +### Git操作機能(13-16) +13. [クローン(Clone)](#13-クローンclone) +14. [プッシュ(Push)](#14-プッシュpush) +15. [プル(Pull)](#15-プルpull) +16. [マージ(Merge)](#16-マージmerge) + +### 拡張機能(17-20) +17. [ディスカッション(Discussions)](#17-ディスカッションdiscussions) +18. [ギスト(Gist)](#18-ギストgist) +19. [パッケージ(Packages)](#19-パッケージpackages) +20. [スポンサー(Sponsors)](#20-スポンサーsponsors) + +--- + +## 1. 📁 リポジトリ(Repository) + +### 概要 +リポジトリは、プロジェクトの全ファイル、履歴、設定を保存する基本単位です。Googleドライブのフォルダに似ていますが、変更履歴を完全に記録し、複数人での同時編集を可能にします。 + +### 詳細機能 + +#### リポジトリの種類 +``` +┌─────────────────────────────────────────────┐ +│ リポジトリタイプ │ +├─────────────────┬───────────────────────────┤ +│ Public │ Private │ +├─────────────────┼───────────────────────────┤ +│ ✓ 誰でも閲覧可 │ ✓ 招待者のみ閲覧可 │ +│ ✓ 検索可能 │ ✗ 検索不可 │ +│ ✓ 無料・無制限 │ ✓ 無料(個人) │ +│ ✓ GitHub Pages │ ✓ Pro版でPages可 │ +└─────────────────┴───────────────────────────┘ +``` + +#### 必須ファイル構成 +``` +my-project/ +├── README.md # プロジェクト説明(必須) +├── LICENSE # ライセンス情報 +├── .gitignore # 無視ファイル設定 +├── .github/ # GitHub設定 +│ ├── workflows/ # Actions設定 +│ ├── ISSUE_TEMPLATE/ +│ ├── PULL_REQUEST_TEMPLATE.md +│ └── CODEOWNERS # コードオーナー +├── docs/ # ドキュメント +├── src/ # ソースコード +└── tests/ # テストコード +``` + +### 実践例 + +#### 1. テンプレートからリポジトリ作成 +```bash +# GitHub CLIを使用 +gh repo create my-app --template owner/template-repo --public + +# テンプレート使用の利点 +- 標準構成の即時適用 +- CI/CD設定の継承 +- コーディング規約の統一 +``` + +#### 2. モノレポ構成 +``` +company-monorepo/ +├── packages/ +│ ├── frontend/ # Reactアプリ +│ ├── backend/ # Node.js API +│ ├── mobile/ # React Native +│ └── shared/ # 共通ライブラリ +├── lerna.json # Lernaモノレポ設定 +└── package.json # ルート設定 +``` + +#### 3. リポジトリ設定のベストプラクティス +```yaml +# .github/settings.yml (probot/settings使用) +repository: + name: my-project + description: プロジェクトの説明 + private: false + has_issues: true + has_projects: true + has_wiki: true + has_downloads: true + default_branch: main + allow_squash_merge: true + allow_merge_commit: true + allow_rebase_merge: false + delete_branch_on_merge: true + enable_automated_security_fixes: true +``` + +### 高度な活用 + +#### 1. リポジトリインサイト分析 +``` +Insights → 各種分析 +├── Pulse: 週次/月次アクティビティ +├── Contributors: 貢献者統計 +├── Community: コミュニティ健全性 +├── Traffic: アクセス統計 +├── Commits: コミット頻度 +├── Code frequency: コード追加/削除 +└── Dependency graph: 依存関係 +``` + +#### 2. セキュリティ設定 +```yaml +# Security → Settings +- ✓ Dependency alerts +- ✓ Dependabot security updates +- ✓ Code scanning alerts +- ✓ Secret scanning alerts +``` + +#### 3. アクセス管理 +``` +Settings → Manage access +├── Collaborators: 個別招待 +├── Teams: チーム単位管理 +└── Deploy keys: CI/CD用鍵 +``` + +### トラブルシューティング + +#### リポジトリサイズ問題 +```bash +# 大きなファイルの履歴削除 +git filter-branch --force --index-filter \ + "git rm --cached --ignore-unmatch path/to/large-file" \ + --prune-empty --tag-name-filter cat -- --all + +# Git LFS導入 +git lfs track "*.psd" +git lfs track "*.zip" +git add .gitattributes +``` + +--- + +## 2. 🌿 ブランチ(Branch) + +### 概要 +ブランチは、メインのコードから分岐して独立した開発を行うための仕組みです。複数の機能を並行開発したり、実験的な変更を安全に試すことができます。 + +### ブランチ戦略 + +#### 1. Git Flow +``` +main (production) +│ +├── develop (開発統合) +│ ├── feature/user-auth +│ ├── feature/payment +│ └── feature/notifications +│ +├── release/v1.2.0 +│ └── 本番リリース準備 +│ +└── hotfix/critical-bug + └── 緊急修正 +``` + +#### 2. GitHub Flow(シンプル) +``` +main +├── feature/new-feature +├── fix/bug-123 +└── docs/update-readme +``` + +#### 3. GitLab Flow(環境別) +``` +main +├── pre-production +├── production +└── feature-branches +``` + +### 実践的なブランチ運用 + +#### ブランチ命名規則 +```bash +# 機能追加 +feature/user-authentication +feature/JIRA-123-shopping-cart + +# バグ修正 +fix/login-error +bugfix/issue-456 + +# ドキュメント +docs/api-documentation +docs/installation-guide + +# リファクタリング +refactor/database-optimization +chore/update-dependencies + +# リリース +release/v2.0.0 +release/2023-12-01 +``` + +#### ブランチ保護ルール +```yaml +# branch protection rules +main: + required_reviews: 2 + dismiss_stale_reviews: true + require_code_owner_reviews: true + required_status_checks: + - continuous-integration/travis-ci + - security/snyk + enforce_admins: false + restrictions: + users: [] + teams: ["maintainers"] +``` + +### 高度なブランチ操作 + +#### 1. ブランチの比較とマージ予測 +```bash +# ブランチ間の差分確認 +git diff main..feature/new-feature + +# マージ予測(ドライラン) +git merge --no-commit --no-ff feature/new-feature +git diff --cached +git merge --abort # 取り消し + +# コンフリクト事前確認 +git log --oneline --left-right main...feature/new-feature +``` + +#### 2. ブランチのクリーンアップ +```bash +# マージ済みブランチ一覧 +git branch --merged main + +# リモートの削除済みブランチを反映 +git remote prune origin + +# 一括削除スクリプト +git branch --merged main | grep -v "main\|develop" | xargs -n 1 git branch -d +``` + +#### 3. ブランチ復元 +```bash +# 削除したブランチを復元 +git reflog +git checkout -b recovered-branch HEAD@{2} +``` + +### ワークフロー例 + +#### フィーチャーブランチワークフロー +```bash +# 1. 最新のmainから分岐 +git checkout main +git pull origin main +git checkout -b feature/awesome-feature + +# 2. 開発作業 +# ... コード変更 ... +git add . +git commit -m "feat: add awesome feature" + +# 3. 定期的にmainの変更を取り込む +git checkout main +git pull origin main +git checkout feature/awesome-feature +git rebase main + +# 4. プッシュしてPR作成 +git push origin feature/awesome-feature +gh pr create --fill +``` + +--- + +## 3. 💾 コミット(Commit) + +### 概要 +コミットは、ファイルの変更を履歴として記録する操作です。各コミットは一意のIDを持ち、いつでも過去の状態に戻すことができます。 + +### コミットメッセージの規約 + +#### Conventional Commits +``` +(): + + + +