12 Commits
Author SHA1 Message Date
Tom Chien (IQ-AS) 16c53c9fc8 Merge branch 'dev'
CI/CD (dev on branch, prod on tag) / build-and-deploy (push) Successful in 5m13s
2026-11-17 19:20:02 +08:00
Tom Chien (IQ-AS) af26029f1e test
CI/CD (dev on branch, prod on tag) / build-and-deploy (push) Successful in 4m4s
2026-11-17 19:17:01 +08:00
Tom Chien (IQ-AS) 1ff7ebbdf9 fis host name
CI/CD (dev on branch, prod on tag) / build-and-deploy (push) Failing after 35s
2026-11-17 19:15:32 +08:00
Tom Chien (IQ-AS) 396a0d0e6a Merge branch 'dev'
CI/CD (dev on branch, prod on tag) / build-and-deploy (push) Successful in 4m52s
2026-11-17 19:05:53 +08:00
Tom Chien (IQ-AS) 93324bf50a modify URL
CI/CD (dev on branch, prod on tag) / build-and-deploy (push) Successful in 4m11s
2026-11-17 17:42:30 +08:00
Tom Chien (IQ-AS) fcf7fb851b modify URL
CI/CD (dev on branch, prod on tag) / build-and-deploy (push) Successful in 3m28s
2026-11-17 15:58:05 +08:00
Tom Chien (IQ-AS) b3c14b5c86 ci: drop dynamic matrix (unsupported by act_runner), compute env config in bash
CI/CD (dev on branch, prod on tag) / build-and-deploy (push) Successful in 5m0s
2026-11-17 15:05:28 +08:00
Tom Chien (IQ-AS)andClaude Opus 4.6 3e5eee0c68 Install kubectl and helm at job start
CI/CD (dev on branch, prod on tag) / setup (push) Successful in 11s
CI/CD (dev on branch, prod on tag) / build-and-deploy (push) Failing after 1m10s
The runner's job image only ships docker; download static binaries so
the diagnostics and deploy steps work.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-11-17 14:59:42 +08:00
Tom Chien (IQ-AS)andClaude Opus 4.6 fb8b3fdcfb Serve the UI over plain HTTP only (POC)
CI/CD (dev on branch, prod on tag) / setup (push) Successful in 9s
CI/CD (dev on branch, prod on tag) / build-and-deploy (push) Failing after 28s
Drop the ingress TLS block and cert-manager annotation, disable the
nginx ssl-redirect, and hardcode AUTH_URL to http://<ingress.host>.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-11-17 14:57:56 +08:00
Tom Chien (IQ-AS)andClaude Opus 4.6 64275f8544 Use runner's actual label ubuntu-latest in runs-on
CI/CD (dev on branch, prod on tag) / setup (push) Successful in 4m3s
CI/CD (dev on branch, prod on tag) / build-and-deploy (push) Failing after 1m24s
The act_runner registered with default labels (name gitea-runner is not a
label), so jobs with runs-on: gitea-runner never matched an online runner.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-11-17 14:40:48 +08:00
s871077 d09a9fa47b Merge branch 'dev' 2026-09-22 10:50:33 +08:00
s871077 d976c0ff4f Remove .env.production.example from master 2026-09-16 17:37:44 +08:00
5 changed files with 99 additions and 104 deletions
+93 -94
View File
@@ -8,32 +8,16 @@ on:
- "*" # build & deploy for prod only when a tag is pushed - "*" # build & deploy for prod only when a tag is pushed
jobs: jobs:
setup:
# Gitea Actions: runners are selected by label only (no runner groups).
runs-on: gitea-runner
outputs:
matrix: ${{ steps.pick.outputs.matrix }}
steps:
- name: Pick matrix config from ref type
id: pick
shell: bash
run: |
if [[ "${{ github.ref_type }}" == "tag" ]]; then
echo 'matrix={"include":[{"env":"prod","image_name_server":"it-cost-dashboard-server-prod","image_name_db":"it-cost-dashboard-db-prod","latest_tag":"latest-prod","release":"it-cost-dashboard-prod","namespace":"it-cost-dashboard-prod","chart":"./helm","values_file":"./helm/values-prod.yaml"}]}' >> "$GITHUB_OUTPUT"
else
echo 'matrix={"include":[{"env":"dev","image_name_server":"it-cost-dashboard-server-dev","image_name_db":"it-cost-dashboard-db-dev","latest_tag":"latest-dev","release":"it-cost-dashboard-dev","namespace":"it-cost-dashboard-dev","chart":"./helm","values_file":"./helm/values-dev.yaml"}]}' >> "$GITHUB_OUTPUT"
fi
build-and-deploy: build-and-deploy:
needs: setup # Gitea Actions: runners are selected by label only (no runner groups).
runs-on: gitea-runner runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJSON(needs.setup.outputs.matrix) }}
# Per-environment group: a dev push must never cancel an in-flight prod # Per-environment group: a dev push must never cancel an in-flight prod
# deploy (the original used a hardcoded "prod" group for both refs). # deploy. NOTE: act_runner does not support dynamic matrix (fromJSON of a
# job output expands every matrix.* to ""), so per-env config is computed
# in the "Resolve environment config" bash step below instead.
concurrency: concurrency:
group: deploy-${{ matrix.env }} group: deploy-${{ github.ref_type == 'tag' && 'prod' || 'dev' }}
cancel-in-progress: true cancel-in-progress: true
env: env:
@@ -52,8 +36,34 @@ jobs:
with: with:
fetch-depth: 0 # IMPORTANT to access tags fetch-depth: 0 # IMPORTANT to access tags
# Replaces the former setup job + dynamic matrix (unsupported on
# act_runner). Everything derived from the ref type lands in GITHUB_ENV
# so later steps can use plain $VARS.
- name: Resolve environment config
shell: bash
run: |
if [[ "${{ github.ref_type }}" == "tag" ]]; then
DEPLOY_ENV=prod
RELEASE_TAG="${GITHUB_REF#refs/tags/}"
else
DEPLOY_ENV=dev
RELEASE_TAG=""
fi
{
echo "DEPLOY_ENV=${DEPLOY_ENV}"
echo "RELEASE_TAG=${RELEASE_TAG}"
echo "IMAGE_SERVER=${REGISTRY}/it-cost-dashboard-server-${DEPLOY_ENV}"
echo "IMAGE_DB=${REGISTRY}/it-cost-dashboard-db-${DEPLOY_ENV}"
echo "LATEST_TAG=latest-${DEPLOY_ENV}"
echo "RELEASE=it-cost-dashboard-${DEPLOY_ENV}"
echo "NAMESPACE=it-cost-dashboard-${DEPLOY_ENV}"
echo "CHART=./helm"
echo "VALUES_FILE=./helm/values-${DEPLOY_ENV}.yaml"
} >> "$GITHUB_ENV"
echo "Resolved environment: ${DEPLOY_ENV} (release tag: '${RELEASE_TAG}')"
- name: Verify tag is on prod branch (main) - name: Verify tag is on prod branch (main)
id: guard
if: github.ref_type == 'tag' if: github.ref_type == 'tag'
shell: bash shell: bash
run: | run: |
@@ -65,6 +75,22 @@ jobs:
exit 1 exit 1
fi fi
# The runner's job image ships docker but not kubectl/helm, so install
# them at job start (static binaries, linux/amd64).
- name: Install kubectl & helm
run: |
if ! command -v kubectl >/dev/null 2>&1; then
KVER=$(curl -sfL https://dl.k8s.io/release/stable.txt)
curl -sfL -o /usr/local/bin/kubectl "https://dl.k8s.io/release/${KVER}/bin/linux/amd64/kubectl"
chmod +x /usr/local/bin/kubectl
fi
if ! command -v helm >/dev/null 2>&1; then
curl -sfL https://get.helm.sh/helm-v3.16.4-linux-amd64.tar.gz | tar xz -C /tmp
mv /tmp/linux-amd64/helm /usr/local/bin/helm
fi
kubectl version --client
helm version
- name: Set up kubeconfig - name: Set up kubeconfig
run: | run: |
echo "KUBECONFIG=${RUNNER_TEMP}/kubeconfig" >> "$GITHUB_ENV" echo "KUBECONFIG=${RUNNER_TEMP}/kubeconfig" >> "$GITHUB_ENV"
@@ -80,47 +106,25 @@ jobs:
-u "${{ secrets.HARBOR_USERNAME }}" \ -u "${{ secrets.HARBOR_USERNAME }}" \
--password-stdin --password-stdin
- name: Determine ref type and release tag
id: refinfo
shell: bash
run: |
echo "GITHUB_REF=${GITHUB_REF}"
echo "GITHUB_REF_TYPE=${GITHUB_REF_TYPE:-${{ github.ref_type }}}"
if [[ "${{ github.ref_type }}" == "tag" ]]; then
echo "ref_type=tag" >> $GITHUB_OUTPUT
echo "release_tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
elif [[ "${{ github.ref_type }}" == "branch" ]]; then
echo "ref_type=branch" >> $GITHUB_OUTPUT
echo "release_tag=" >> $GITHUB_OUTPUT
else
echo "ref_type=unknown" >> $GITHUB_OUTPUT
echo "release_tag=" >> $GITHUB_OUTPUT
fi
- name: Pre-build diagnostics - name: Pre-build diagnostics
run: | run: |
echo "Ref: ${GITHUB_REF}" echo "Ref: ${GITHUB_REF}"
echo "Ref type: ${{ steps.refinfo.outputs.ref_type }}" echo "Environment: ${DEPLOY_ENV}"
echo "Release tag: ${{ steps.refinfo.outputs.release_tag }}" echo "Release tag: ${RELEASE_TAG}"
echo "Environment: ${{ matrix.env }}" echo "Server image: ${IMAGE_SERVER}"
echo "Server image: ${REGISTRY}/${{ matrix.image_name_server }}" echo "DB image: ${IMAGE_DB}"
echo "DB image: ${REGISTRY}/${{ matrix.image_name_db }}"
docker version docker version
helm version helm version
kubectl version --client kubectl version --client
- name: Build & Push server image - name: Build & Push server image
run: | run: |
REF_TYPE="${{ steps.refinfo.outputs.ref_type }}"
RELEASE_TAG="${{ steps.refinfo.outputs.release_tag }}"
IMAGE="${REGISTRY}/${{ matrix.image_name_server }}"
BUILD_TAG_ARGS=( BUILD_TAG_ARGS=(
-t "${IMAGE}:${{ matrix.latest_tag }}" -t "${IMAGE_SERVER}:${LATEST_TAG}"
-t "${IMAGE}:${{ github.sha }}" -t "${IMAGE_SERVER}:${{ github.sha }}"
) )
if [[ "${REF_TYPE}" == "tag" && -n "${RELEASE_TAG}" ]]; then if [[ -n "${RELEASE_TAG}" ]]; then
BUILD_TAG_ARGS+=( -t "${IMAGE}:${RELEASE_TAG}" ) BUILD_TAG_ARGS+=( -t "${IMAGE_SERVER}:${RELEASE_TAG}" )
fi fi
# AUTH_SECRET is build-time only (Auth.js v5 initializes NextAuth() at # AUTH_SECRET is build-time only (Auth.js v5 initializes NextAuth() at
@@ -131,24 +135,20 @@ jobs:
"${BUILD_TAG_ARGS[@]}" \ "${BUILD_TAG_ARGS[@]}" \
. .
docker push "${IMAGE}:${{ matrix.latest_tag }}" docker push "${IMAGE_SERVER}:${LATEST_TAG}"
docker push "${IMAGE}:${{ github.sha }}" docker push "${IMAGE_SERVER}:${{ github.sha }}"
if [[ "${REF_TYPE}" == "tag" && -n "${RELEASE_TAG}" ]]; then if [[ -n "${RELEASE_TAG}" ]]; then
docker push "${IMAGE}:${RELEASE_TAG}" docker push "${IMAGE_SERVER}:${RELEASE_TAG}"
fi fi
- name: Build & Push db image - name: Build & Push db image
run: | run: |
REF_TYPE="${{ steps.refinfo.outputs.ref_type }}"
RELEASE_TAG="${{ steps.refinfo.outputs.release_tag }}"
IMAGE="${REGISTRY}/${{ matrix.image_name_db }}"
BUILD_TAG_ARGS=( BUILD_TAG_ARGS=(
-t "${IMAGE}:${{ matrix.latest_tag }}" -t "${IMAGE_DB}:${LATEST_TAG}"
-t "${IMAGE}:${{ github.sha }}" -t "${IMAGE_DB}:${{ github.sha }}"
) )
if [[ "${REF_TYPE}" == "tag" && -n "${RELEASE_TAG}" ]]; then if [[ -n "${RELEASE_TAG}" ]]; then
BUILD_TAG_ARGS+=( -t "${IMAGE}:${RELEASE_TAG}" ) BUILD_TAG_ARGS+=( -t "${IMAGE_DB}:${RELEASE_TAG}" )
fi fi
docker build \ docker build \
@@ -156,16 +156,16 @@ jobs:
"${BUILD_TAG_ARGS[@]}" \ "${BUILD_TAG_ARGS[@]}" \
. .
docker push "${IMAGE}:${{ matrix.latest_tag }}" docker push "${IMAGE_DB}:${LATEST_TAG}"
docker push "${IMAGE}:${{ github.sha }}" docker push "${IMAGE_DB}:${{ github.sha }}"
if [[ "${REF_TYPE}" == "tag" && -n "${RELEASE_TAG}" ]]; then if [[ -n "${RELEASE_TAG}" ]]; then
docker push "${IMAGE}:${RELEASE_TAG}" docker push "${IMAGE_DB}:${RELEASE_TAG}"
fi fi
- name: Ensure namespace exists - name: Ensure namespace exists
run: | run: |
# `helm --atomic` against a missing namespace fails outright. # `helm --atomic` against a missing namespace fails outright.
kubectl create namespace "${{ matrix.namespace }}" \ kubectl create namespace "${NAMESPACE}" \
--dry-run=client -o yaml | kubectl apply -f - --dry-run=client -o yaml | kubectl apply -f -
# The kubelet pulls through the same Docker Desktop daemon that built the # The kubelet pulls through the same Docker Desktop daemon that built the
@@ -177,7 +177,7 @@ jobs:
--docker-server="$(echo "${REGISTRY}" | cut -d'/' -f1)" \ --docker-server="$(echo "${REGISTRY}" | cut -d'/' -f1)" \
--docker-username="${{ secrets.HARBOR_USERNAME }}" \ --docker-username="${{ secrets.HARBOR_USERNAME }}" \
--docker-password="${{ secrets.HARBOR_PASSWORD }}" \ --docker-password="${{ secrets.HARBOR_PASSWORD }}" \
--namespace "${{ matrix.namespace }}" \ --namespace "${NAMESPACE}" \
--dry-run=client -o yaml | kubectl apply -f - --dry-run=client -o yaml | kubectl apply -f -
# ---- DEV DEPLOY (branch dev only) ---- # ---- DEV DEPLOY (branch dev only) ----
@@ -190,12 +190,12 @@ jobs:
kubectl get nodes kubectl get nodes
kubectl get ns kubectl get ns
helm upgrade --install "${{ matrix.release }}" "${{ matrix.chart }}" \ helm upgrade --install "${RELEASE}" "${CHART}" \
-f "${{ matrix.values_file }}" \ -f "${VALUES_FILE}" \
--namespace "${{ matrix.namespace }}" \ --namespace "${NAMESPACE}" \
--set server.image.repository="${REGISTRY}/${{ matrix.image_name_server }}" \ --set server.image.repository="${IMAGE_SERVER}" \
--set server.image.tag="${{ github.sha }}" \ --set server.image.tag="${{ github.sha }}" \
--set db.image.repository="${REGISTRY}/${{ matrix.image_name_db }}" \ --set db.image.repository="${IMAGE_DB}" \
--set db.image.tag="${{ github.sha }}" \ --set db.image.tag="${{ github.sha }}" \
--set-string secrets.authSecret="${{ secrets.AUTH_SECRET_DEV }}" \ --set-string secrets.authSecret="${{ secrets.AUTH_SECRET_DEV }}" \
--set-string secrets.dbRootPassword="${{ secrets.DB_PASSWORD_DEV }}" \ --set-string secrets.dbRootPassword="${{ secrets.DB_PASSWORD_DEV }}" \
@@ -209,19 +209,18 @@ jobs:
kubectl get nodes kubectl get nodes
kubectl get ns kubectl get ns
TAG="${GITHUB_REF#refs/tags/}" if [[ -z "${RELEASE_TAG}" ]]; then
if [[ -z "${TAG}" ]]; then
echo "No tag detected; aborting prod deploy." echo "No tag detected; aborting prod deploy."
exit 1 exit 1
fi fi
helm upgrade --install "${{ matrix.release }}" "${{ matrix.chart }}" \ helm upgrade --install "${RELEASE}" "${CHART}" \
-f "${{ matrix.values_file }}" \ -f "${VALUES_FILE}" \
--namespace "${{ matrix.namespace }}" \ --namespace "${NAMESPACE}" \
--set server.image.repository="${REGISTRY}/${{ matrix.image_name_server }}" \ --set server.image.repository="${IMAGE_SERVER}" \
--set server.image.tag="${TAG}" \ --set server.image.tag="${RELEASE_TAG}" \
--set db.image.repository="${REGISTRY}/${{ matrix.image_name_db }}" \ --set db.image.repository="${IMAGE_DB}" \
--set db.image.tag="${TAG}" \ --set db.image.tag="${RELEASE_TAG}" \
--set-string secrets.authSecret="${{ secrets.AUTH_SECRET_PROD }}" \ --set-string secrets.authSecret="${{ secrets.AUTH_SECRET_PROD }}" \
--set-string secrets.dbRootPassword="${{ secrets.DB_PASSWORD_PROD }}" \ --set-string secrets.dbRootPassword="${{ secrets.DB_PASSWORD_PROD }}" \
--set-string secrets.localAdminPassword="${{ secrets.LOCAL_ADMIN_PASSWORD_PROD }}" \ --set-string secrets.localAdminPassword="${{ secrets.LOCAL_ADMIN_PASSWORD_PROD }}" \
@@ -231,23 +230,23 @@ jobs:
# pods and --atomic already verified health. Retained as belt-and-braces. # pods and --atomic already verified health. Retained as belt-and-braces.
# Scoped to component=server so it does not bounce MySQL every push. # Scoped to component=server so it does not bounce MySQL every push.
- name: Rollout restart (server only) - name: Rollout restart (server only)
if: success() && (github.ref_type == 'branch' || github.ref_type == 'tag') if: success()
run: | run: |
kubectl rollout restart deployment \ kubectl rollout restart deployment \
-l "app.kubernetes.io/instance=${{ matrix.release }},app.kubernetes.io/component=server" \ -l "app.kubernetes.io/instance=${RELEASE},app.kubernetes.io/component=server" \
-n "${{ matrix.namespace }}" -n "${NAMESPACE}"
- name: Post-deploy diagnostics (if failure) - name: Post-deploy diagnostics (if failure)
if: failure() if: failure()
run: | run: |
echo "----- Diagnostics -----" echo "----- Diagnostics -----"
kubectl get deploy,sts,po,svc,ing -n "${{ matrix.namespace }}" -o wide || true kubectl get deploy,sts,po,svc,ing -n "${NAMESPACE}" -o wide || true
echo "----- PVCs (a Pending PVC = missing/wrong StorageClass; invisible in pod logs) -----" echo "----- PVCs (a Pending PVC = missing/wrong StorageClass; invisible in pod logs) -----"
kubectl get pvc -n "${{ matrix.namespace }}" -o wide || true kubectl get pvc -n "${NAMESPACE}" -o wide || true
echo "----- Events -----" echo "----- Events -----"
kubectl get events -n "${{ matrix.namespace }}" --sort-by=.lastTimestamp || true kubectl get events -n "${NAMESPACE}" --sort-by=.lastTimestamp || true
for p in $(kubectl get po -n "${{ matrix.namespace }}" -o name); do for p in $(kubectl get po -n "${NAMESPACE}" -o name); do
echo "### $p" echo "### $p"
kubectl describe "$p" -n "${{ matrix.namespace }}" || true kubectl describe "$p" -n "${NAMESPACE}" || true
kubectl logs "$p" -n "${{ matrix.namespace }}" --all-containers --tail=200 || true kubectl logs "$p" -n "${NAMESPACE}" --all-containers --tail=200 || true
done done
+2 -5
View File
@@ -10,13 +10,10 @@ metadata:
# Headroom for large request headers (chunked Auth.js session cookies). # Headroom for large request headers (chunked Auth.js session cookies).
nginx.ingress.kubernetes.io/proxy-buffer-size: "16k" nginx.ingress.kubernetes.io/proxy-buffer-size: "16k"
nginx.ingress.kubernetes.io/proxy-buffers-number: "4" nginx.ingress.kubernetes.io/proxy-buffers-number: "4"
cert-manager.io/cluster-issuer: sectigo-acme # POC runs plain HTTP — no TLS, no redirect to https.
nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec: spec:
ingressClassName: {{ .Values.ingress.className }} ingressClassName: {{ .Values.ingress.className }}
tls:
- hosts:
- {{ .Values.ingress.host | quote }}
secretName: {{ include "it-cost-dashboard.fullname" . }}-server-tls
rules: rules:
- host: {{ required "ingress.host is required" .Values.ingress.host | quote }} - host: {{ required "ingress.host is required" .Values.ingress.host | quote }}
http: http:
+2 -3
View File
@@ -20,6 +20,5 @@ stringData:
LOCAL_ADMIN_PASSWORD: {{ required "secrets.localAdminPassword is required" .Values.secrets.localAdminPassword | quote }} LOCAL_ADMIN_PASSWORD: {{ required "secrets.localAdminPassword is required" .Values.secrets.localAdminPassword | quote }}
# Derived from the ingress host so Auth.js builds correct absolute redirect # Derived from the ingress host so Auth.js builds correct absolute redirect
# URLs regardless of X-Forwarded-Proto. Local Docker Desktop ingress has no # URLs. POC UI is plain HTTP only (no TLS anywhere).
# TLS, so the scheme is http (override ingress.scheme if TLS is added later). AUTH_URL: {{ printf "http://%s" (required "ingress.host is required" .Values.ingress.host) | quote }}
AUTH_URL: {{ printf "%s://%s" (.Values.ingress.scheme | default "http") (required "ingress.host is required" .Values.ingress.host) | quote }}
+1 -1
View File
@@ -32,4 +32,4 @@ ingress:
className: nginx className: nginx
# Local ingress hostname — map it to the Mac mini's IP (192.168.0.31) in # Local ingress hostname — map it to the Mac mini's IP (192.168.0.31) in
# /etc/hosts or local DNS. # /etc/hosts or local DNS.
host: it-cost-dashboard-dev.local host: it-cost-dev.tomchien.com
+1 -1
View File
@@ -32,4 +32,4 @@ ingress:
className: nginx className: nginx
# Local ingress hostname — map it to the Mac mini's IP (192.168.0.31) in # Local ingress hostname — map it to the Mac mini's IP (192.168.0.31) in
# /etc/hosts or local DNS. # /etc/hosts or local DNS.
host: it-cost-dashboard-prod.local host: it-cost-prod.tomchien.com