CI/CD nemusí být složité. Tady je funkční pipeline za 5 minut.
GitHub Actions — základní workflow¶
.github/workflows/ci.yml¶
name: CI on: [push, pull_request] jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: { node-version: 20 } - run: npm ci - run: npm test - run: npm run build
Docker build + push¶
build: needs: test runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: docker/build-push-action@v5 with: push: true tags: ghcr.io/${{ github.repository }}:${{ github.sha }}
Deploy¶
deploy: needs: build if: github.ref == ‘refs/heads/main’ runs-on: ubuntu-latest steps: - run: kubectl set image deployment/app app=ghcr.io/$REPO:$SHA
Secrets¶
Settings → Secrets → New repository secret¶
Použití: ${{ secrets.KUBE_CONFIG }}¶
Caching¶
- uses: actions/cache@v4 with: path: ~/.npm key: ${{ runner.os }}-npm-${{ hashFiles(‘package-lock.json’) }}
To je vše¶
5 souborů, 5 minut. Push → test → build → deploy. Rozšiřujte postupně.