Fix CI: use git clone instead of actions/checkout, host mode without GitHub access.
Build and Deploy Platform / build-and-deploy (push) Failing after 20m1s
Build and Deploy Platform / build-and-deploy (push) Failing after 20m1s
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -11,34 +11,41 @@ env:
|
|||||||
REGISTRY: harbor-registry.cloudhost.svc.cluster.local:5000
|
REGISTRY: harbor-registry.cloudhost.svc.cluster.local:5000
|
||||||
PROJECT: abrban
|
PROJECT: abrban
|
||||||
BUILD_NS: cloudhost-builds
|
BUILD_NS: cloudhost-builds
|
||||||
|
GITEA_URL: http://gitea-http.gitea.svc.cluster.local:3000
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-deploy:
|
build-and-deploy:
|
||||||
runs-on: abrban-builder
|
runs-on: abrban-builder
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
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
|
- name: Set image tag
|
||||||
shell: sh
|
shell: sh
|
||||||
run: |
|
run: |
|
||||||
SHA="${GITHUB_SHA:-$(git rev-parse HEAD)}"
|
cd workspace
|
||||||
TAG="$(date +%Y%m%d-%H%M)-$(echo $SHA | cut -c1-8)"
|
SHA="$(git rev-parse --short HEAD)"
|
||||||
|
TAG="$(date +%Y%m%d-%H%M)-${SHA}"
|
||||||
echo "IMAGE_TAG=${TAG}" >> "$GITHUB_ENV"
|
echo "IMAGE_TAG=${TAG}" >> "$GITHUB_ENV"
|
||||||
echo "Build tag: ${TAG}"
|
echo "Build tag: ${TAG}"
|
||||||
|
|
||||||
- name: Build backend image (Kaniko Job)
|
- name: Build backend image (Kaniko Job)
|
||||||
shell: sh
|
shell: sh
|
||||||
run: |
|
run: |
|
||||||
|
JOB_NAME="build-be-$(echo $IMAGE_TAG | tr '.:' '-' | cut -c1-50)"
|
||||||
cat <<ENDJOB | kubectl apply -f -
|
cat <<ENDJOB | kubectl apply -f -
|
||||||
apiVersion: batch/v1
|
apiVersion: batch/v1
|
||||||
kind: Job
|
kind: Job
|
||||||
metadata:
|
metadata:
|
||||||
name: build-backend-${IMAGE_TAG}
|
name: ${JOB_NAME}
|
||||||
namespace: ${BUILD_NS}
|
namespace: ${BUILD_NS}
|
||||||
spec:
|
spec:
|
||||||
ttlSecondsAfterFinished: 600
|
ttlSecondsAfterFinished: 600
|
||||||
backoffLimit: 1
|
backoffLimit: 0
|
||||||
template:
|
template:
|
||||||
spec:
|
spec:
|
||||||
restartPolicy: Never
|
restartPolicy: Never
|
||||||
@@ -46,16 +53,17 @@ jobs:
|
|||||||
- name: registry-pull-secret
|
- name: registry-pull-secret
|
||||||
initContainers:
|
initContainers:
|
||||||
- name: clone
|
- name: clone
|
||||||
image: ${REGISTRY}/${PROJECT}/act-runner:0.2.11
|
image: ${REGISTRY}/${PROJECT}/alpine:3
|
||||||
command: ["sh", "-c", "git clone --depth=1 --branch main http://gitea-http.gitea.svc.cluster.local:3000/abrban/cloud-host.git /workspace"]
|
command:
|
||||||
|
- sh
|
||||||
|
- -c
|
||||||
|
- apk add --no-cache git && git clone --depth=1 --branch main ${GITEA_URL}/abrban/cloud-host.git /workspace
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: ws
|
- name: ws
|
||||||
mountPath: /workspace
|
mountPath: /workspace
|
||||||
containers:
|
containers:
|
||||||
- name: kaniko
|
- name: kaniko
|
||||||
image: ${REGISTRY}/${PROJECT}/kaniko-executor:v1.27.6-debug
|
image: ${REGISTRY}/${PROJECT}/kaniko-executor:v1.27.6-debug
|
||||||
command:
|
|
||||||
- /kaniko/executor
|
|
||||||
args:
|
args:
|
||||||
- --dockerfile=/workspace/backend/Dockerfile
|
- --dockerfile=/workspace/backend/Dockerfile
|
||||||
- --context=dir:///workspace/backend
|
- --context=dir:///workspace/backend
|
||||||
@@ -69,22 +77,23 @@ jobs:
|
|||||||
- name: ws
|
- name: ws
|
||||||
emptyDir: {}
|
emptyDir: {}
|
||||||
ENDJOB
|
ENDJOB
|
||||||
echo "Waiting for backend build..."
|
echo "Waiting for backend build job: ${JOB_NAME}"
|
||||||
kubectl -n ${BUILD_NS} wait --for=condition=complete job/build-backend-${IMAGE_TAG} --timeout=20m
|
kubectl -n ${BUILD_NS} wait --for=condition=complete job/${JOB_NAME} --timeout=20m
|
||||||
echo "Backend build done"
|
echo "Backend build done"
|
||||||
|
|
||||||
- name: Build frontend image (Kaniko Job)
|
- name: Build frontend image (Kaniko Job)
|
||||||
shell: sh
|
shell: sh
|
||||||
run: |
|
run: |
|
||||||
|
JOB_NAME="build-fe-$(echo $IMAGE_TAG | tr '.:' '-' | cut -c1-50)"
|
||||||
cat <<ENDJOB | kubectl apply -f -
|
cat <<ENDJOB | kubectl apply -f -
|
||||||
apiVersion: batch/v1
|
apiVersion: batch/v1
|
||||||
kind: Job
|
kind: Job
|
||||||
metadata:
|
metadata:
|
||||||
name: build-frontend-${IMAGE_TAG}
|
name: ${JOB_NAME}
|
||||||
namespace: ${BUILD_NS}
|
namespace: ${BUILD_NS}
|
||||||
spec:
|
spec:
|
||||||
ttlSecondsAfterFinished: 600
|
ttlSecondsAfterFinished: 600
|
||||||
backoffLimit: 1
|
backoffLimit: 0
|
||||||
template:
|
template:
|
||||||
spec:
|
spec:
|
||||||
restartPolicy: Never
|
restartPolicy: Never
|
||||||
@@ -92,16 +101,17 @@ jobs:
|
|||||||
- name: registry-pull-secret
|
- name: registry-pull-secret
|
||||||
initContainers:
|
initContainers:
|
||||||
- name: clone
|
- name: clone
|
||||||
image: ${REGISTRY}/${PROJECT}/act-runner:0.2.11
|
image: ${REGISTRY}/${PROJECT}/alpine:3
|
||||||
command: ["sh", "-c", "git clone --depth=1 --branch main http://gitea-http.gitea.svc.cluster.local:3000/abrban/cloud-host.git /workspace"]
|
command:
|
||||||
|
- sh
|
||||||
|
- -c
|
||||||
|
- apk add --no-cache git && git clone --depth=1 --branch main ${GITEA_URL}/abrban/cloud-host.git /workspace
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: ws
|
- name: ws
|
||||||
mountPath: /workspace
|
mountPath: /workspace
|
||||||
containers:
|
containers:
|
||||||
- name: kaniko
|
- name: kaniko
|
||||||
image: ${REGISTRY}/${PROJECT}/kaniko-executor:v1.27.6-debug
|
image: ${REGISTRY}/${PROJECT}/kaniko-executor:v1.27.6-debug
|
||||||
command:
|
|
||||||
- /kaniko/executor
|
|
||||||
args:
|
args:
|
||||||
- --dockerfile=/workspace/frontend/Dockerfile
|
- --dockerfile=/workspace/frontend/Dockerfile
|
||||||
- --context=dir:///workspace/frontend
|
- --context=dir:///workspace/frontend
|
||||||
@@ -116,20 +126,19 @@ jobs:
|
|||||||
- name: ws
|
- name: ws
|
||||||
emptyDir: {}
|
emptyDir: {}
|
||||||
ENDJOB
|
ENDJOB
|
||||||
echo "Waiting for frontend build..."
|
echo "Waiting for frontend build job: ${JOB_NAME}"
|
||||||
kubectl -n ${BUILD_NS} wait --for=condition=complete job/build-frontend-${IMAGE_TAG} --timeout=20m
|
kubectl -n ${BUILD_NS} wait --for=condition=complete job/${JOB_NAME} --timeout=20m
|
||||||
echo "Frontend build done"
|
echo "Frontend build done"
|
||||||
|
|
||||||
- name: Update GitOps values
|
- name: Update GitOps values and push
|
||||||
shell: sh
|
shell: sh
|
||||||
run: |
|
run: |
|
||||||
|
cd workspace
|
||||||
sed -i "s|tag: \"[^\"]*\"|tag: \"${IMAGE_TAG}\"|g" gitops/platform/values-abrban.yaml
|
sed -i "s|tag: \"[^\"]*\"|tag: \"${IMAGE_TAG}\"|g" gitops/platform/values-abrban.yaml
|
||||||
git config user.email "ci@abrban.com"
|
git config user.email "ci@abrban.com"
|
||||||
git config user.name "Gitea Actions"
|
git config user.name "Gitea Actions"
|
||||||
git add gitops/platform/values-abrban.yaml
|
git add gitops/platform/values-abrban.yaml
|
||||||
git diff --cached --quiet || git commit -m "ci: deploy platform ${IMAGE_TAG}"
|
if ! git diff --cached --quiet; then
|
||||||
|
git commit -m "ci: deploy platform ${IMAGE_TAG}"
|
||||||
- name: Push GitOps update
|
git push origin HEAD:main
|
||||||
shell: sh
|
fi
|
||||||
run: |
|
|
||||||
git push origin HEAD:main
|
|
||||||
|
|||||||
Reference in New Issue
Block a user