fix: add shell: bash to CI steps — maven container uses sh by default

This commit is contained in:
2026-07-26 22:06:33 +08:00
parent 09e67cd834
commit 65ee61c6c9
+11 -1
View File
@@ -25,6 +25,7 @@ jobs:
- maven-cache:/root/.m2 - maven-cache:/root/.m2
steps: steps:
- name: Validate branch ↔ environment - name: Validate branch ↔ environment
shell: bash
run: | run: |
set -euo pipefail set -euo pipefail
REF="${{ gitea.ref }}" REF="${{ gitea.ref }}"
@@ -64,6 +65,7 @@ jobs:
esac esac
- name: Checkout code - name: Checkout code
shell: bash
run: | run: |
set -euo pipefail set -euo pipefail
# maven 容器可能无 git # maven 容器可能无 git
@@ -75,6 +77,7 @@ jobs:
git checkout "${{ gitea.sha }}" git checkout "${{ gitea.sha }}"
- name: Install Docker CLI - name: Install Docker CLI
shell: bash
run: | run: |
set -euo pipefail set -euo pipefail
apt-get update -qq apt-get update -qq
@@ -82,16 +85,19 @@ jobs:
docker --version docker --version
- name: Build with Maven - name: Build with Maven
shell: bash
run: | run: |
set -euo pipefail set -euo pipefail
mvn clean package -DskipTests -B mvn clean package -DskipTests -B
- name: Login to Docker Registry - name: Login to Docker Registry
shell: bash
run: | run: |
set -euo pipefail set -euo pipefail
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login "$REGISTRY" -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login "$REGISTRY" -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin
- name: Build & Push Docker image - name: Build & Push Docker image
shell: bash
run: | run: |
set -euo pipefail set -euo pipefail
ENV="${{ inputs.environment }}" ENV="${{ inputs.environment }}"
@@ -106,13 +112,13 @@ jobs:
if [ -n "${GITEA_ENV:-}" ]; then if [ -n "${GITEA_ENV:-}" ]; then
echo "IMAGE_TAG=$TAG" >> "$GITEA_ENV" echo "IMAGE_TAG=$TAG" >> "$GITEA_ENV"
fi fi
# runner.temp 在 container job 里可能不可用,用工作区文件兜底
echo "$TAG" > image_tag.txt echo "$TAG" > image_tag.txt
mkdir -p /tmp/lpt-ci mkdir -p /tmp/lpt-ci
echo "$TAG" > /tmp/lpt-ci/image_tag.txt echo "$TAG" > /tmp/lpt-ci/image_tag.txt
echo "IMAGE_TAG=$TAG" echo "IMAGE_TAG=$TAG"
- name: Setup kubectl - name: Setup kubectl
shell: bash
run: | run: |
set -euo pipefail set -euo pipefail
curl -sLO "https://dl.k8s.io/release/v1.30.0/bin/linux/amd64/kubectl" curl -sLO "https://dl.k8s.io/release/v1.30.0/bin/linux/amd64/kubectl"
@@ -122,6 +128,7 @@ jobs:
echo "${{ secrets.KUBECONFIG_B64 }}" | base64 -d > ~/.kube/config echo "${{ secrets.KUBECONFIG_B64 }}" | base64 -d > ~/.kube/config
- name: Create/Update imagePullSecret - name: Create/Update imagePullSecret
shell: bash
run: | run: |
set -euo pipefail set -euo pipefail
kubectl create secret docker-registry regcred \ kubectl create secret docker-registry regcred \
@@ -132,6 +139,7 @@ jobs:
--dry-run=client -o yaml | kubectl apply -f - --dry-run=client -o yaml | kubectl apply -f -
- name: Deploy to K8s - name: Deploy to K8s
shell: bash
run: | run: |
set -euo pipefail set -euo pipefail
ENV="${{ inputs.environment }}" ENV="${{ inputs.environment }}"
@@ -156,6 +164,7 @@ jobs:
- name: Debug on failure - name: Debug on failure
if: failure() if: failure()
shell: bash
run: | run: |
ENV="${{ inputs.environment }}" ENV="${{ inputs.environment }}"
echo "=== Deployment Status ===" echo "=== Deployment Status ==="
@@ -178,6 +187,7 @@ jobs:
- name: Rollback on failure - name: Rollback on failure
if: failure() if: failure()
shell: bash
run: | run: |
set -euo pipefail set -euo pipefail
ENV="${{ inputs.environment }}" ENV="${{ inputs.environment }}"