fix: use real BUILD_ID via env var, switch to Harbor registry
Some checks failed
Build & Deploy / build (push) Failing after 21s
Some checks failed
Build & Deploy / build (push) Failing after 21s
This commit is contained in:
@@ -5,7 +5,7 @@ on:
|
|||||||
branches: [main]
|
branches: [main]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: zot-registry.cicd.svc.cluster.local:5000
|
REGISTRY: 192.168.1.212:1180/library
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@@ -23,28 +23,31 @@ jobs:
|
|||||||
[ -d .git ] || git clone http://joe:${GITEA_TOKEN}@192.168.1.212:3000/joe/demo-frontend.git .
|
[ -d .git ] || git clone http://joe:${GITEA_TOKEN}@192.168.1.212:3000/joe/demo-frontend.git .
|
||||||
git pull
|
git pull
|
||||||
|
|
||||||
cat > package.json <<'EOF'
|
SHORT_SHA=${GITHUB_SHA::8}
|
||||||
|
cat > package.json <<EOF
|
||||||
{
|
{
|
||||||
"name": "demo-frontend",
|
"name": "demo-frontend",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"scripts": {"build": "mkdir -p dist && echo '<html><body style=\"font-family:sans-serif;padding:40px;text-align:center\"><h1>Demo Frontend</h1><p>Build: $BUILD_ID</p></body></html>' > dist/index.html"}
|
"scripts": {"build": "mkdir -p dist && echo '<html><body style=\"font-family:sans-serif;padding:40px;text-align:center\"><h1>Demo Frontend</h1><p>Build: ${SHORT_SHA}</p><p>Commit: ${GITHUB_SHA}</p><p>Time: \$(date)</p></body></html>' > dist/index.html"}
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat > Dockerfile <<'EOF'
|
cat > Dockerfile <<EOF
|
||||||
FROM nginx:alpine
|
FROM nginx:alpine
|
||||||
COPY dist/ /usr/share/nginx/html/
|
COPY dist/ /usr/share/nginx/html/
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
EOF
|
EOF
|
||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
BUILD_ID: ${{ github.sha }}
|
GITHUB_SHA: ${{ github.sha }}
|
||||||
|
|
||||||
- name: Build frontend
|
- name: Build frontend
|
||||||
run: |
|
run: |
|
||||||
cd /root/.cache/demo-frontend
|
cd /root/.cache/demo-frontend
|
||||||
npm install --silent
|
npm install --silent
|
||||||
npm run build
|
npm run build
|
||||||
|
env:
|
||||||
|
GITHUB_SHA: ${{ github.sha }}
|
||||||
|
|
||||||
- name: Docker build & push
|
- name: Docker build & push
|
||||||
run: |
|
run: |
|
||||||
@@ -59,15 +62,13 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITHUB_SHA: ${{ github.sha }}
|
GITHUB_SHA: ${{ github.sha }}
|
||||||
|
|
||||||
- name: Patch ArgoCD Application
|
- name: Patch ArgoCD
|
||||||
run: |
|
run: |
|
||||||
SHORT=${GITHUB_SHA::8}
|
SHORT=${GITHUB_SHA::8}
|
||||||
if kubectl -n argocd get application demo-frontend &>/dev/null; then
|
if kubectl -n argocd get application demo-frontend &>/dev/null; then
|
||||||
kubectl -n argocd patch application demo-frontend --type merge \
|
kubectl -n argocd patch application demo-frontend --type merge \
|
||||||
-p "{\"spec\":{\"source\":{\"helm\":{\"parameters\":[{\"name\":\"image.tag\",\"value\":\"${SHORT}\"}]}}}}"
|
-p "{\"spec\":{\"source\":{\"helm\":{\"parameters\":[{\"name\":\"image.tag\",\"value\":\"${SHORT}\"}]}}}}"
|
||||||
echo "✓ ArgoCD app patched"
|
echo "✓ ArgoCD app patched"
|
||||||
else
|
|
||||||
echo "⚠ demo-frontend Application not found in argocd namespace (create it manually)"
|
|
||||||
fi
|
fi
|
||||||
env:
|
env:
|
||||||
GITHUB_SHA: ${{ github.sha }}
|
GITHUB_SHA: ${{ github.sha }}
|
||||||
|
|||||||
Reference in New Issue
Block a user