Claude Code के साथ CI/CD Pipelines बनाने की Complete Guide
Claude Code का उपयोग करके CI/CD pipelines बनाने की व्यापक guide, practical examples और best practices के साथ।
Claude Code से CI/CD Pipeline निर्माण को कुशल बनाएं
CI/CD की configuration files में बहुत सारी बारीकियां होती हैं, और trial-and-error में समय लग जाता है। Claude Code का उपयोग करके, आप अपने project के लिए उपयुक्त pipeline एक ही बार में generate कर सकते हैं।
GitHub Actions का Basic Workflow
> GitHub Actions का workflow बनाओ।
> - PR बनने पर lint, type check, और test चलाओ
> - main में merge होने पर build और deploy करो
> - Node.js 20, pnpm का उपयोग करो
> - Cache setup करके speed बढ़ाओ
# .github/workflows/ci.yml
name: CI
on:
pull_request:
branches: [main]
push:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- run: pnpm install --frozen-lockfile
- name: Lint
run: pnpm lint
- name: Type Check
run: pnpm tsc --noEmit
- name: Test
run: pnpm test -- --coverage
- name: Upload Coverage
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: coverage
path: coverage/
deploy:
needs: lint-and-test
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm build
- name: Deploy to Vercel
uses: amondnet/vercel-action@v25
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
vercel-args: --prod
Docker Image का Build और Push
> Docker image build और GitHub Container Registry में
> push करने के लिए workflow बनाओ।
> Tag git tag और commit SHA से करो।
# .github/workflows/docker.yml
name: Docker Build
on:
push:
tags: ["v*"]
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/metadata-action@v5
id: meta
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=sha,prefix=
- uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
Docker environment setup के बारे में Docker integration guide में विस्तार से बताया गया है।
E2E Test का Integration
> Playwright के E2E test को CI/CD में शामिल करो।
> Test fail होने पर screenshot save करो।
e2e-test:
needs: lint-and-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: npx playwright install --with-deps chromium
- name: Run E2E Tests
run: pnpm test:e2e
- uses: actions/upload-artifact@v4
if: failure()
with:
name: playwright-report
path: playwright-report/
retention-days: 7
Testing strategy की पूरी तस्वीर के लिए testing strategy complete guide देखें, और Git workflow के साथ integration के लिए Git operations को पूरी तरह automate करें भी देखें।
Security Scan जोड़ना
> Dependency packages की vulnerability scan को CI में जोड़ो।
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npx audit-ci --moderate
Security check के details security audit automation में बताए गए हैं।
Summary
Claude Code का उपयोग करके, आप कम समय में अपने project के लिए optimal CI/CD pipeline बना सकते हैं। lint, test, build, deploy के हर stage को स्पष्ट रूप से instruct करके, production-ready workflow generate होता है।
GitHub Actions के details के लिए GitHub Actions official documentation, और Claude Code के बारे में Anthropic official documentation देखें।
Related Posts
Claude Code Hooks में Mastery: Auto-Format, Auto-Test, और बहुत कुछ
Claude Code hooks से auto-formatting और auto-testing setup करना सीखें। Practical configuration examples और real-world use cases शामिल हैं।
Claude Code MCP Server Setup और Practical Use Cases
Claude Code की MCP server capabilities की comprehensive guide। External tools connect करना, servers configure करना, और real-world integration examples सीखें।
CLAUDE.md लिखने की Complete Guide: Project Configuration की Best Practices
Effective CLAUDE.md files लिखने की thorough guide। अपना tech stack, conventions, और project structure communicate करना सीखें और Claude Code की output quality maximize करें।