mcpField
G
github-actions-cicd

github-actions-cicd

github.com/hack23クラウド・DevOps13141 回インストール今日更新
リポジトリ

github-actions-cicd について

github-actions-cicdは、テストやセキュリティスキャン、デプロイを自動化するGitHub ActionsのCI/CDスキルです。最小権限、シークレット保護、本番デプロイ時の承認を重視します。

主な機能

  1. 01コード品質チェックの計画
  2. 02セキュリティスキャンと性能監査の追加
  3. 03プロジェクトのビルドと圧縮
  4. 04承認付き本番デプロイの設定
  5. 05シークレットと権限の保護ルール適用

活用シーン

  1. 01GitHub ActionsのCI/CDワークフロー設計
  2. 02ワークフローのAWS OIDC認証設定
  3. 03Actionのバージョン固定とトークン権限の確認
  4. 04本番リリース承認の計画

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/hack23/homepage --skill github-actions-cicd

インストール後、Claude Code で/github-actions-cicdを入力して読み込まれたか確認します。

詳細

GitHub Actions CI/CD スキル

目的

自動テスト、セキュリティスキャン、デプロイにおいて、GitHub Actions を使用する CI/CD パイプラインのベストプラクティスを定義します。

ルール

ワークフローの構成

必ず含める項目:

  1. コード品質チェック(リンティング、フォーマット)
  2. セキュリティスキャン(CodeQL、Dependabot、ZAP)
  3. パフォーマンス監査(Lighthouse)
  4. ビルドと圧縮
  5. デプロイ(本番環境では承認を必須にする)

ワークフローの例:

name: CI/CD Pipeline

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

permissions:
  contents: read
  security-events: write

jobs:
  validate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Validate HTML
        run: npm run validate:html
      - name: Lint CSS
        run: npm run lint:css

  security-scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Initialize CodeQL
        uses: github/codeql-action/init@v3
      - name: Perform CodeQL Analysis
        uses: github/codeql-action/analyze@v3
      - name: ZAP Baseline Scan
        uses: zaproxy/[email protected]
        with:
          target: 'https://www.hack23.com'

  lighthouse:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Run Lighthouse
        uses: treosh/lighthouse-ci-action@v10
        with:
          urls: |
            https://www.hack23.com/
            https://www.hack23.com/services.html
          budgetPath: ./budget.json
          uploadArtifacts: true

  deploy:
    needs: [validate, security-scan, lighthouse]
    runs-on: ubuntu-latest
    if: github.ref == 'refs/heads/main'
    steps:
      - uses: actions/checkout@v4
      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
          aws-region: us-east-1
      - name: Sync to S3
        run: aws s3 sync . s3://${{ secrets.S3_BUCKET }} --delete
      - name: Invalidate CloudFront
        run: aws cloudfront create-invalidation --distribution-id ${{ secrets.CF_DIST_ID }} --paths "/*"
セキュリティのベストプラクティス

必ず行うこと:

  • AWS 認証には OIDC を使用する(長期間有効なキーは使用しない)
  • シークレットは GitHub Secrets に保存する
  • 最小権限の IAM ロールを使用する
  • アクションのバージョンは完全なコミット SHA で固定する
  • アクションの更新に Dependabot を有効にする
  • permissions キーを使用してトークンの権限範囲を最小限にする

禁止事項:

  • リポジトリにシークレットをコミットする
  • ワークフローで個人アクセストークンを使用する
  • 過度に広範な権限を付与する

関連ドキュメント

コメント