CI/CD muss nicht kompliziert sein. Hier ist eine funktionierende Pipeline in 5 Minuten.
GitHub Actions — Grundlegender 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¶
Verwendung: ${{ secrets.KUBE_CONFIG }}¶
Caching¶
- uses: actions/cache@v4 with: path: ~/.npm key: ${{ runner.os }}-npm-${{ hashFiles(‘package-lock.json’) }}
Das war’s¶
5 Dateien, 5 Minuten. Push → Test → Build → Deploy. Schrittweise erweitern.