This commit is contained in:
@@ -44,28 +44,25 @@ jobs:
|
|||||||
|
|
||||||
- name: Update image tag in values.yaml (commit-back GitOps)
|
- name: Update image tag in values.yaml (commit-back GitOps)
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -ex
|
||||||
WORK=/root/.cache/demo-go-api
|
WORK=/root/.cache/demo-go-api
|
||||||
cd $WORK
|
cd $WORK
|
||||||
SHORT=${GITHUB_SHA::8}
|
SHORT=${GITHUB_SHA::8}
|
||||||
echo "Updating tag to ${SHORT}"
|
echo "=== Updating tag to ${SHORT} ==="
|
||||||
# Set up git auth using token
|
pwd
|
||||||
git remote set-url origin "http://joe:${GITEA_TOKEN}@192.168.1.212:3000/joe/demo-go-api.git"
|
ls -la
|
||||||
git config user.email "ci@local"
|
cat deploy/helm/values.yaml
|
||||||
git config user.name "gitea-ci"
|
git status
|
||||||
|
git remote -v
|
||||||
# Update tag in values.yaml
|
# Update tag in values.yaml
|
||||||
sed -i "s/^ tag:.*/ tag: \"${SHORT}\"/" deploy/helm/values.yaml
|
sed -i "s/^ tag:.*/ tag: \"${SHORT}\"/" deploy/helm/values.yaml
|
||||||
echo "--- diff ---"
|
echo "--- after sed ---"
|
||||||
git diff deploy/helm/values.yaml || true
|
cat deploy/helm/values.yaml
|
||||||
# Check if there are changes
|
git config user.email "ci@local"
|
||||||
if git diff --quiet deploy/helm/values.yaml; then
|
git config user.name "gitea-ci"
|
||||||
echo "No changes to commit"
|
git remote set-url origin "http://joe:${GITEA_TOKEN}@192.168.1.212:3000/joe/demo-go-api.git"
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
# Pull latest to avoid conflicts
|
|
||||||
git pull --rebase origin main || git pull origin main --rebase
|
|
||||||
git add deploy/helm/values.yaml
|
git add deploy/helm/values.yaml
|
||||||
git commit -m "ci: update image tag to ${SHORT}"
|
git commit -m "ci: update image tag to ${SHORT}" || echo "nothing to commit"
|
||||||
git push origin main
|
git push origin main
|
||||||
echo "✓ Pushed tag ${SHORT}"
|
echo "✓ Pushed tag ${SHORT}"
|
||||||
env:
|
env:
|
||||||
|
|||||||
Reference in New Issue
Block a user