name: Build & Deploy on: push: branches: [main] env: REGISTRY: zot-registry.cicd.svc.cluster.local:5000 jobs: build: runs-on: self-hosted steps: - name: Install build tools run: | apk add --no-cache curl git nodejs npm docker-cli 2>/dev/null || true - name: Generate demo content + Dockerfile run: | WORK=/root/.cache/demo-frontend mkdir -p $WORK cd $WORK [ -d .git ] || git clone http://joe:${GITEA_TOKEN}@192.168.1.212:3000/joe/demo-frontend.git . git pull cat > package.json <<'EOF' { "name": "demo-frontend", "version": "1.0.0", "scripts": {"build": "mkdir -p dist && echo '

Demo Frontend

Build: $BUILD_ID

' > dist/index.html"} } EOF cat > Dockerfile <<'EOF' FROM nginx:alpine COPY dist/ /usr/share/nginx/html/ EXPOSE 80 EOF env: GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} BUILD_ID: ${{ github.sha }} - name: Build frontend run: | cd /root/.cache/demo-frontend npm install --silent npm run build - name: Docker build & push run: | cd /root/.cache/demo-frontend SHORT=${GITHUB_SHA::8} TAG="${REGISTRY}/demo-frontend:${SHORT}" LATEST="${REGISTRY}/demo-frontend:latest" docker build -t "${TAG}" -t "${LATEST}" . docker push "${TAG}" docker push "${LATEST}" echo "✓ Pushed ${TAG}" env: GITHUB_SHA: ${{ github.sha }} - name: Patch ArgoCD Application run: | SHORT=${GITHUB_SHA::8} if kubectl -n argocd get application demo-frontend &>/dev/null; then kubectl -n argocd patch application demo-frontend --type merge \ -p "{\"spec\":{\"source\":{\"helm\":{\"parameters\":[{\"name\":\"image.tag\",\"value\":\"${SHORT}\"}]}}}}" echo "✓ ArgoCD app patched" else echo "⚠ demo-frontend Application not found in argocd namespace (create it manually)" fi env: GITHUB_SHA: ${{ github.sha }}