name: Build and Deploy Platform on: push: branches: [main] paths-ignore: - "**.md" workflow_dispatch: # Serialize builds so parallel pushes don't race on the GitOps values update. concurrency: group: build-deploy-platform cancel-in-progress: false env: # PULL_REGISTRY: kubelet pulls via k3s mirror → harbor-core (matches registry-pull-secret) PULL_REGISTRY: registry.abrban.com # PUSH_REGISTRY: kaniko pushes directly to harbor-registry (internal, no TLS) PUSH_REGISTRY: harbor-registry.cloudhost.svc.cluster.local:5000 PROJECT: abrban BUILD_NS: cloudhost-builds GITEA_HOST: gitea-http.gitea.svc.cluster.local:3000 # PAT of the "ci" user, stored as repo secret CI_TOKEN (names starting with GITEA_ are reserved) GITEA_TOKEN: ${{ secrets.CI_TOKEN }} REPO_PATH: abrban/cloud-host.git GITOPS_REPO_PATH: abrban/cloud-host-gitops.git jobs: build-and-deploy: runs-on: abrban-builder steps: - name: Checkout shell: sh run: | git clone --depth=1 --branch main "http://oauth2:${GITEA_TOKEN}@${GITEA_HOST}/${REPO_PATH}" workspace cd workspace echo "Checked out $(git rev-parse --short HEAD)" - name: Set image tag shell: sh run: | cd workspace SHA="$(git rev-parse --short HEAD)" TAG="$(date +%Y%m%d-%H%M)-${SHA}" echo "IMAGE_TAG=${TAG}" >> "$GITHUB_ENV" echo "Build tag: ${TAG}" - name: Build backend image (Kaniko Job) shell: sh run: | JOB_NAME="build-be-$(echo $IMAGE_TAG | tr '.:' '-' | cut -c1-50)" cat </dev/null 2>&1; then IMAGE_TAG="${IMAGE_TAG}" yq -i '.images.backend.tag = strenv(IMAGE_TAG) | .images.frontend.tag = strenv(IMAGE_TAG)' "${VALUES}" else # Only touch the tag line directly below each cloudhost-* repository line. sed -i "/repository: .*cloudhost-backend/{n;s|tag: \".*\"|tag: \"${IMAGE_TAG}\"|;}" "${VALUES}" sed -i "/repository: .*cloudhost-frontend/{n;s|tag: \".*\"|tag: \"${IMAGE_TAG}\"|;}" "${VALUES}" fi git config user.email "ci@abrban.com" git config user.name "Gitea Actions" git add "${VALUES}" if ! git diff --cached --quiet; then git commit -m "ci: deploy platform ${IMAGE_TAG}" git push origin HEAD:main fi