From c1df1f646568b1d27ec163fda116d5f73cedb5b6 Mon Sep 17 00:00:00 2001 From: cialloo Date: Sat, 4 Oct 2025 23:25:53 +0800 Subject: [PATCH] update --- .github/workflows/cd.yml | 6 ++++++ script/cd.sh | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 6a79003..2bbb86d 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -21,6 +21,11 @@ on: required: false default: '' type: string + force_restart: + description: 'Force rollout restart (restarts pods even if no changes)' + required: false + default: true + type: boolean env: # Kubernetes configuration @@ -36,6 +41,7 @@ env: CONTAINER_REGISTRY_PASSWORD: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }} CONTAINER_IMAGE_NAME: ${{ secrets.CONTAINER_IMAGE_NAME }} CONTAINER_IMAGE_TAG: ${{ inputs.image_tag || 'latest' }} + FORCE_RESTART: ${{ inputs.force_restart }} # Application configuration DATABASE_DSN: ${{ secrets.DATABASE_DSN }} diff --git a/script/cd.sh b/script/cd.sh index 67fe507..7c385d0 100644 --- a/script/cd.sh +++ b/script/cd.sh @@ -23,6 +23,7 @@ CONTAINER_IMAGE_TAG="${CONTAINER_IMAGE_TAG:-latest}" # Application Configuration DATABASE_DSN="${DATABASE_DSN:-postgres://postgres:password@localhost:5432/steam_union?sslmode=disable}" +FORCE_RESTART="${FORCE_RESTART:-true}" # ============================================================================= # Functions @@ -43,8 +44,9 @@ print_help() { echo " CONTAINER_IMAGE_NAME Image name (default: stats-api)" echo " CONTAINER_IMAGE_TAG Image tag (default: latest)" echo " DATABASE_DSN Database connection string" + echo " FORCE_RESTART Force rollout restart (default: true)" echo "" - echo "Commands:" + echo "Commands: echo " deploy Deploy application to Kubernetes" echo " help Show this help message (default)" } @@ -134,6 +136,13 @@ deploy_to_kubernetes() { echo "✓ Deployment complete" echo "" echo "Waiting for rollout..." + + # Force restart if enabled + if [ "${FORCE_RESTART}" = "true" ]; then + echo "Forcing rollout restart..." + kubectl rollout restart deployment/${CONTAINER_IMAGE_NAME} -n ${KUBERNETES_NAMESPACE} + fi + kubectl rollout status deployment/${CONTAINER_IMAGE_NAME} -n ${KUBERNETES_NAMESPACE} --timeout=300s if [ $? -eq 0 ]; then