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