Files
cloud-host/.gitea/workflows/build-deploy.yaml
T
keyhan d4559920d1
Build and Deploy Platform / build-and-deploy (push) Failing after 20m1s
Fix CI: use git clone instead of actions/checkout, host mode without GitHub access.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-02 02:07:40 +03:30

145 lines
5.2 KiB
YAML

name: Build and Deploy Platform
on:
push:
branches: [main]
paths-ignore:
- "gitops/platform/values-abrban.yaml"
- "**.md"
workflow_dispatch:
env:
REGISTRY: harbor-registry.cloudhost.svc.cluster.local:5000
PROJECT: abrban
BUILD_NS: cloudhost-builds
GITEA_URL: http://gitea-http.gitea.svc.cluster.local:3000
jobs:
build-and-deploy:
runs-on: abrban-builder
steps:
- name: Checkout
shell: sh
run: |
git clone --depth=1 --branch main "${GITEA_URL}/abrban/cloud-host.git" 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 <<ENDJOB | kubectl apply -f -
apiVersion: batch/v1
kind: Job
metadata:
name: ${JOB_NAME}
namespace: ${BUILD_NS}
spec:
ttlSecondsAfterFinished: 600
backoffLimit: 0
template:
spec:
restartPolicy: Never
imagePullSecrets:
- name: registry-pull-secret
initContainers:
- name: clone
image: ${REGISTRY}/${PROJECT}/alpine:3
command:
- sh
- -c
- apk add --no-cache git && git clone --depth=1 --branch main ${GITEA_URL}/abrban/cloud-host.git /workspace
volumeMounts:
- name: ws
mountPath: /workspace
containers:
- name: kaniko
image: ${REGISTRY}/${PROJECT}/kaniko-executor:v1.27.6-debug
args:
- --dockerfile=/workspace/backend/Dockerfile
- --context=dir:///workspace/backend
- --destination=${REGISTRY}/${PROJECT}/cloudhost-backend:${IMAGE_TAG}
- --insecure
- --skip-tls-verify
volumeMounts:
- name: ws
mountPath: /workspace
volumes:
- name: ws
emptyDir: {}
ENDJOB
echo "Waiting for backend build job: ${JOB_NAME}"
kubectl -n ${BUILD_NS} wait --for=condition=complete job/${JOB_NAME} --timeout=20m
echo "Backend build done"
- name: Build frontend image (Kaniko Job)
shell: sh
run: |
JOB_NAME="build-fe-$(echo $IMAGE_TAG | tr '.:' '-' | cut -c1-50)"
cat <<ENDJOB | kubectl apply -f -
apiVersion: batch/v1
kind: Job
metadata:
name: ${JOB_NAME}
namespace: ${BUILD_NS}
spec:
ttlSecondsAfterFinished: 600
backoffLimit: 0
template:
spec:
restartPolicy: Never
imagePullSecrets:
- name: registry-pull-secret
initContainers:
- name: clone
image: ${REGISTRY}/${PROJECT}/alpine:3
command:
- sh
- -c
- apk add --no-cache git && git clone --depth=1 --branch main ${GITEA_URL}/abrban/cloud-host.git /workspace
volumeMounts:
- name: ws
mountPath: /workspace
containers:
- name: kaniko
image: ${REGISTRY}/${PROJECT}/kaniko-executor:v1.27.6-debug
args:
- --dockerfile=/workspace/frontend/Dockerfile
- --context=dir:///workspace/frontend
- --build-arg=NEXT_PUBLIC_API_URL=https://api.abrban.com
- --destination=${REGISTRY}/${PROJECT}/cloudhost-frontend:${IMAGE_TAG}
- --insecure
- --skip-tls-verify
volumeMounts:
- name: ws
mountPath: /workspace
volumes:
- name: ws
emptyDir: {}
ENDJOB
echo "Waiting for frontend build job: ${JOB_NAME}"
kubectl -n ${BUILD_NS} wait --for=condition=complete job/${JOB_NAME} --timeout=20m
echo "Frontend build done"
- name: Update GitOps values and push
shell: sh
run: |
cd workspace
sed -i "s|tag: \"[^\"]*\"|tag: \"${IMAGE_TAG}\"|g" gitops/platform/values-abrban.yaml
git config user.email "ci@abrban.com"
git config user.name "Gitea Actions"
git add gitops/platform/values-abrban.yaml
if ! git diff --cached --quiet; then
git commit -m "ci: deploy platform ${IMAGE_TAG}"
git push origin HEAD:main
fi