ci: improve commit-back step with rebase and auth
Some checks failed
Build & Deploy Go API / build (push) Failing after 21s
Some checks failed
Build & Deploy Go API / build (push) Failing after 21s
This commit is contained in:
@@ -49,15 +49,21 @@ jobs:
|
|||||||
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
|
||||||
|
git remote set-url origin "http://joe:${GITEA_TOKEN}@192.168.1.212:3000/joe/demo-go-api.git"
|
||||||
|
git config user.email "ci@local"
|
||||||
|
git config user.name "gitea-ci"
|
||||||
|
# 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 "--- diff ---"
|
||||||
git diff deploy/helm/values.yaml || true
|
git diff deploy/helm/values.yaml || true
|
||||||
git config user.email "ci@local"
|
# Check if there are changes
|
||||||
git config user.name "gitea-ci"
|
|
||||||
if git diff --quiet deploy/helm/values.yaml; then
|
if git diff --quiet deploy/helm/values.yaml; then
|
||||||
echo "No changes to commit"
|
echo "No changes to commit"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
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}"
|
||||||
git push origin main
|
git push origin main
|
||||||
|
|||||||
Reference in New Issue
Block a user