fix: update Docker image version in deployment manifest and automate Git commit

This commit is contained in:
2026-01-11 19:48:28 +08:00
parent a7eb17fc4b
commit 0b2c48ee26

View File

@@ -53,19 +53,15 @@ jobs:
- name: Push Docker image to local registry - name: Push Docker image to local registry
run: | run: |
docker push localhost:8180/k8s-example/k8s-example:${{ gitea.sha }} docker push localhost:8180/k8s-example/k8s-example:${{ gitea.sha }}
- name: Check kubectl - name: Update manifest and Push to Git
run: | run: |
kubectl version --client # 使用 kustomize 或 sed 修改镜像版本
- name: Set up Kubeconfig sed -i "s|image: .*:.*|image: localhost:8180/k8s-example/k8s-example:${{ gitea.sha }}|g" deployment.yaml
run: |
mkdir -p $HOME/.kube # 配置 Git 并提交回仓库
echo "${{ secrets.KUBECONFIG_DATA }}" | base64 --decode > $HOME/.kube/config git config --global user.name "Gitea Action"
- name: Deploy to Kubernetes git config --global user.email "action@gitea.io"
run: | git add deployment.yaml
cd ${{ gitea.workspace }} git commit -m "chore: update image to ${{ gitea.sha }} [skip ci]"
sed -i "s|localhost:8180/k8s-example/k8s-example:latest|localhost:8180/k8s-example/k8s-example:${{ gitea.sha }}|g" deployment.yaml git push origin main
cat deployment.yaml
echo
echo "Applying Kubernetes deployment..."
kubectl apply -f deployment.yaml
- run: echo "🍏 This job's status is ${{ job.status }}." - run: echo "🍏 This job's status is ${{ job.status }}."