NFTT-GitHub-Workflows

使用パターン集

📋 概要

NFTT-GitHub-Workflowsの実践的な使用パターンを紹介します。プロジェクトの規模や目的に応じて、最適なパターンを選択してください。

🚀 インストール方法

ワンクリックインストール

# 方法1: インストールスクリプト
curl -fsSL https://raw.githubusercontent.com/NFTTechnology/NFTT-GitHub-Workflows/main/install.sh | bash

# 方法2: GitHub CLI Extension
gh extension install NFTTechnology/NFTT-GitHub-Workflows --force
gh nftt-workflows install

環境別インストール

CI/CD環境での自動セットアップ

# .github/workflows/setup-nftt.yml
name: Setup NFTT Workflows
on:
  workflow_dispatch:

jobs:
  setup:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install NFTT Workflows
        run: |
          curl -fsSL https://raw.githubusercontent.com/NFTTechnology/NFTT-GitHub-Workflows/main/install.sh | bash -s -- --non-interactive --version v5

Dockerコンテナでの利用

FROM ubuntu:latest
RUN apt-get update && apt-get install -y curl git
RUN curl -fsSL https://raw.githubusercontent.com/NFTTechnology/NFTT-GitHub-Workflows/main/install.sh -o /tmp/install.sh && \
    chmod +x /tmp/install.sh && \
    /tmp/install.sh --non-interactive

🏗️ プロジェクト規模別パターン

小規模プロジェクト(〜10人チーム)

推奨設定

# .github/workflows/simple-3ai.yml
name: 3AI Analysis (Small Team)
on:
  issue_comment:
    types: [created]

jobs:
  analyze:
    if: |
      startsWith(github.event.comment.body, '/analyze') &&
      (github.event.comment.author_association == 'OWNER' ||
       github.event.comment.author_association == 'MEMBER')
    uses: NFTTechnology/NFTT-GitHub-Workflows/.github/workflows/reusable-3ai-issue-analyzer.yml@main
    with:
      issue_number: $
      issue_title: $
      issue_body: $
      repository: $
      # v5使用でコスト最適化
      version: "v5"
    secrets: inherit

特徴

中規模プロジェクト(10〜50人チーム)

推奨設定

# .github/workflows/medium-3ai.yml
name: 3AI Analysis (Medium Team)
on:
  issue_comment:
    types: [created]
  issues:
    types: [opened, labeled]

jobs:
  analyze-comment:
    if: startsWith(github.event.comment.body, '/analyze')
    uses: NFTTechnology/NFTT-GitHub-Workflows/.github/workflows/reusable-3ai-issue-analyzer.yml@main
    with:
      issue_number: $
      issue_title: $
      issue_body: $
      repository: $
    secrets: inherit

  analyze-critical:
    if: |
      github.event_name == 'issues' &&
      contains(github.event.issue.labels.*.name, 'critical')
    uses: NFTTechnology/NFTT-GitHub-Workflows/.github/workflows/reusable-3ai-issue-analyzer.yml@main
    with:
      issue_number: $
      issue_title: $
      issue_body: $
      repository: $
      # 重要なIssueはv4で詳細分析
      version: "v4"
    secrets: inherit

特徴

大規模プロジェクト(50人以上)

推奨設定

# .github/workflows/enterprise-3ai.yml
name: 3AI Analysis (Enterprise)
on:
  issue_comment:
    types: [created]
  workflow_dispatch:
    inputs:
      issue_numbers:
        description: 'Issue numbers to analyze (comma-separated)'
        required: true
      ai_models:
        description: 'AI models to use'
        required: false
        default: 'all'
        type: choice
        options:
          - all
          - claude-only
          - gpt-only
          - gemini-only

jobs:
  check-permissions:
    runs-on: ubuntu-latest
    outputs:
      allowed: $
    steps:
      - id: check
        uses: actions/github-script@v7
        with:
          script: |
            const teams = ['reviewers', 'maintainers'];
            const membership = await github.rest.teams.getMembershipForUserInOrg({
              org: context.repo.owner,
              team_slug: teams[0],
              username: context.actor
            });
            return membership.status === 200;

  analyze:
    needs: check-permissions
    if: needs.check-permissions.outputs.allowed == 'true'
    strategy:
      matrix:
        issue: $
    uses: NFTTechnology/NFTT-GitHub-Workflows/.github/workflows/reusable-3ai-issue-analyzer.yml@main
    with:
      issue_number: $
      ai_models: $
    secrets: inherit

特徴

🎯 目的別パターン

バグ修正の影響分析

name: Bug Impact Analysis
on:
  issues:
    types: [labeled]

jobs:
  analyze-bug:
    if: contains(github.event.issue.labels.*.name, 'bug')
    uses: NFTTechnology/NFTT-GitHub-Workflows/.github/workflows/reusable-3ai-issue-analyzer.yml@main
    with:
      issue_number: $
      issue_title: $
      issue_body: $
      repository: $
      # カスタムプロンプト
      custom_prompt: |
        このバグの影響範囲を分析してください:
        1. 影響を受けるコンポーネント
        2. ユーザーへの影響度
        3. 修正の緊急度
        4. 推奨される修正アプローチ
    secrets: inherit

新機能提案の評価

name: Feature Proposal Evaluation
on:
  issues:
    types: [labeled]

jobs:
  evaluate-feature:
    if: contains(github.event.issue.labels.*.name, 'enhancement')
    uses: NFTTechnology/NFTT-GitHub-Workflows/.github/workflows/reusable-3ai-issue-analyzer.yml@main
    with:
      issue_number: $
      issue_title: $
      issue_body: $
      repository: $
      version: "v4"  # コメント履歴も含めて評価
      custom_prompt: |
        この機能提案を評価してください:
        1. 技術的実現可能性
        2. 既存機能との整合性
        3. 実装工数の見積もり
        4. 潜在的なリスク
    secrets: inherit

セキュリティ脆弱性の分析

name: Security Vulnerability Analysis
on:
  issues:
    types: [labeled]

jobs:
  analyze-security:
    if: contains(github.event.issue.labels.*.name, 'security')
    uses: NFTTechnology/NFTT-GitHub-Workflows/.github/workflows/reusable-3ai-issue-analyzer.yml@main
    with:
      issue_number: $
      issue_title: $
      issue_body: $
      repository: $
      # セキュリティ分析に特化
      custom_prompt: |
        セキュリティの観点から分析してください:
        1. 脆弱性の深刻度(CVSS)
        2. 攻撃ベクトル
        3. 影響範囲
        4. 緊急対応策
        5. 根本的な修正方法
      # プライベートコメントで結果を投稿
      private_comment: true
    secrets: inherit

🔄 統合パターン

Slack通知との連携

name: 3AI with Slack Notification
on:
  issue_comment:
    types: [created]

jobs:
  analyze:
    if: startsWith(github.event.comment.body, '/analyze')
    uses: NFTTechnology/NFTT-GitHub-Workflows/.github/workflows/reusable-3ai-issue-analyzer.yml@main
    with:
      issue_number: $
      issue_title: $
      issue_body: $
      repository: $
    secrets: inherit

  notify:
    needs: analyze
    if: always()
    runs-on: ubuntu-latest
    steps:
      - name: Slack Notification
        uses: 8398a7/action-slack@v3
        with:
          status: $
          text: |
            3AI分析完了
            Issue: #$
            結果: $
        env:
          SLACK_WEBHOOK_URL: $

PRレビューとの組み合わせ

name: Comprehensive Review
on:
  pull_request:
    types: [opened, synchronize]

jobs:
  # 関連Issueの分析
  analyze-linked-issues:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/github-script@v7
        id: get-issues
        with:
          script: |
            const pr = context.payload.pull_request;
            const body = pr.body || '';
            const issueRefs = body.match(/#(\d+)/g) || [];
            return issueRefs.map(ref => ref.substring(1));

      - name: Analyze Issues
        if: steps.get-issues.outputs.result != '[]'
        uses: NFTTechnology/NFTT-GitHub-Workflows/.github/workflows/reusable-3ai-issue-analyzer.yml@main
        with:
          issue_numbers: $
        secrets: inherit

  # PRのコードレビュー
  pr-review:
    uses: NFTTechnology/NFTT-GitHub-Workflows/.github/workflows/reusable-pr-review.yml@main
    with:
      pr_number: $
    secrets: inherit

🚀 高度な使用例

カスタムAI設定

name: Custom AI Configuration
on:
  workflow_dispatch:
    inputs:
      issue_number:
        required: true

jobs:
  custom-analysis:
    uses: NFTTechnology/NFTT-GitHub-Workflows/.github/workflows/reusable-3ai-issue-analyzer.yml@main
    with:
      issue_number: $
      # AI個別設定
      claude_config: |
        model: claude-3-opus-20240229
        max_tokens: 4000
        temperature: 0.3
      openai_config: |
        model: gpt-4-turbo-preview
        max_tokens: 3000
        temperature: 0.5
      gemini_config: |
        model: gemini-pro
        max_output_tokens: 2048
        temperature: 0.4
    secrets: inherit

多言語対応

name: Multilingual Analysis
on:
  issue_comment:
    types: [created]

jobs:
  detect-language:
    runs-on: ubuntu-latest
    outputs:
      language: $
    steps:
      - id: detect
        uses: actions/github-script@v7
        with:
          script: |
            // 簡易的な言語検出
            const body = context.payload.issue.body;
            if (/[\u3040-\u309F\u30A0-\u30FF]/.test(body)) return 'ja';
            if (/[\u4E00-\u9FAF]/.test(body)) return 'zh';
            return 'en';

  analyze:
    needs: detect-language
    uses: NFTTechnology/NFTT-GitHub-Workflows/.github/workflows/reusable-3ai-issue-analyzer.yml@main
    with:
      issue_number: $
      language: $
      custom_prompt: |
        言語: $
        この言語で分析結果を提供してください。
    secrets: inherit

📊 パフォーマンス最適化

並列処理パターン

name: Parallel Analysis
on:
  schedule:
    - cron: '0 2 * * *'  # 毎日深夜2時

jobs:
  get-issues:
    runs-on: ubuntu-latest
    outputs:
      matrix: $
    steps:
      - uses: actions/github-script@v7
        id: set-matrix
        with:
          script: |
            const issues = await github.rest.issues.listForRepo({
              owner: context.repo.owner,
              repo: context.repo.repo,
              labels: 'needs-analysis',
              state: 'open',
              per_page: 20
            });
            return { issues: issues.data.map(i => i.number) };

  analyze:
    needs: get-issues
    strategy:
      matrix: $
      max-parallel: 3  # 同時実行数を制限
    uses: NFTTechnology/NFTT-GitHub-Workflows/.github/workflows/reusable-3ai-issue-analyzer.yml@main
    with:
      issue_number: $
    secrets: inherit

🎯 ベストプラクティス

  1. コスト管理
    • 定期実行は深夜帯に設定
    • 重要度に応じてAIモデルを選択
    • 不要な再実行を防ぐキャッシュ活用
  2. セキュリティ
    • 権限チェックを必須化
    • センシティブ情報は環境変数で管理
    • 実行履歴の定期監査
  3. 保守性
    • ワークフローの共通化
    • 設定値の外部化
    • エラーハンドリングの充実

最終更新: 2025年7月