1+ name : Continuous Integration
2+
3+ env :
4+ # Use docker.io for Docker Hub if empty
5+ REGISTRY : ghcr.io
6+ # github.repository as <account>/<repo>
7+ IMAGE_NAME : ${{ github.repository }}
8+
9+ on :
10+ push :
11+ branches :
12+ - main
13+ paths-ignore :
14+ - ' k8s/**' # Avoid CI runs for updates inside k8s folder
15+
16+ jobs :
17+ ci :
18+ runs-on : ubuntu-latest
19+
20+ steps :
21+ # Step 1: Checkout the repository code
22+ - name : 🛎️ Checkout
23+ uses : actions/checkout@v4
24+ with :
25+ fetch-depth : 0
26+
27+ # Step 2: Extract and normalize repository name into lowercase (e.g., pipeline-api)
28+ - id : imagename
29+ uses : ASzc/change-string-case-action@v6
30+ with :
31+ string : ${{ github.repository }}
32+
33+ # Step 3: Get the current version of the project (assumes `package.json` exists)
34+ - name : 📝 Get Current Version
35+ id : package-version
36+ uses : martinbeentjes/npm-get-version-action@main
37+
38+ # Step 4: Login to Docker Registry (GHCR authentication)
39+ - name : 🔐 Login to Docker Registry
40+ uses : docker/login-action@v3
41+ with :
42+ registry : ghcr.io
43+ username : ${{ github.actor }}
44+ password : ${{ secrets.GITHUB_TOKEN }}
45+
46+ # Step 5: Set up Docker Buildx (required for advanced Docker build features)
47+ - name : 🏗️ Set up Docker Buildx
48+ uses : docker/setup-buildx-action@v3
49+
50+ # Step 6: Build and push Docker image
51+ - name : 🔧 Build and push Docker Image
52+ uses : docker/build-push-action@v6
53+ with :
54+ push : true
55+ tags : |
56+ ${{ env.REGISTRY }}/${{ steps.imagename.outputs.lowercase }}:${{ steps.package-version.outputs.current-version }}
57+ ${{ env.REGISTRY }}/${{ steps.imagename.outputs.lowercase }}:latest
58+ cache-from : type=gha
59+ cache-to : type=gha,mode=max
60+
61+ # Step 7: Update version in package.json to prepare for next development cycle
62+ - name : 🎫 Update patch version
63+ run : |
64+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
65+ git config --global user.name "github-actions[bot]"
66+ git pull --rebase origin main
67+ npm version prerelease --preid=rc # Increment version (e.g., 1.0.0 -> 1.0.1-rc.0)
68+ git push origin main
0 commit comments