github-actions-cicd について
github-actions-cicdは、テストやセキュリティスキャン、デプロイを自動化するGitHub ActionsのCI/CDスキルです。最小権限、シークレット保護、本番デプロイ時の承認を重視します。
主な機能
- 01コード品質チェックの計画
- 02セキュリティスキャンと性能監査の追加
- 03プロジェクトのビルドと圧縮
- 04承認付き本番デプロイの設定
- 05シークレットと権限の保護ルール適用
活用シーン
- 01GitHub ActionsのCI/CDワークフロー設計
- 02ワークフローのAWS OIDC認証設定
- 03Actionのバージョン固定とトークン権限の確認
- 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 パイプラインのベストプラクティスを定義します。
ルール
ワークフローの構成
必ず含める項目:
- コード品質チェック(リンティング、フォーマット)
- セキュリティスキャン(CodeQL、Dependabot、ZAP)
- パフォーマンス監査(Lighthouse)
- ビルドと圧縮
- デプロイ(本番環境では承認を必須にする)
ワークフローの例:
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キーを使用してトークンの権限範囲を最小限にする
禁止事項:
- リポジトリにシークレットをコミットする
- ワークフローで個人アクセストークンを使用する
- 過度に広範な権限を付与する
関連ドキュメント
コメント
Markdown 対応