ci: simplify with fresh clone each run
Some checks failed
Build & Deploy Go API / build (push) Failing after 16s

This commit is contained in:
Joe
2026-07-19 21:01:25 +08:00
parent fc8d7ecaad
commit 5823bb9fc3

View File

@@ -17,14 +17,10 @@ jobs:
- name: Clone + prepare - name: Clone + prepare
run: | run: |
WORK=/root/.cache/demo-go-api WORK=/root/.cache/demo-go-api
mkdir -p $WORK rm -rf "$WORK"
cd $WORK mkdir -p "$WORK"
if [ -d .git ]; then cd "$WORK"
git reset --hard origin/main git clone http://joe:${GITEA_TOKEN}@192.168.1.212:3000/joe/demo-go-api.git .
git clean -fd
else
git clone http://joe:${GITEA_TOKEN}@192.168.1.212:3000/joe/demo-go-api.git .
fi
- name: Login to Harbor - name: Login to Harbor
run: docker login 192.168.1.212:1180 -u admin -p "$HARBOR_PASSWORD" run: docker login 192.168.1.212:1180 -u admin -p "$HARBOR_PASSWORD"
@@ -48,22 +44,13 @@ 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 cd /root/.cache/demo-go-api
WORK=/root/.cache/demo-go-api
cd $WORK
SHORT=${GITHUB_SHA::8} SHORT=${GITHUB_SHA::8}
echo "Updating tag to ${SHORT}"
sed -i "s/^ tag:.*/ tag: \"${SHORT}\"/" deploy/helm/values.yaml sed -i "s/^ tag:.*/ tag: \"${SHORT}\"/" deploy/helm/values.yaml
echo "--- diff ---"
git diff deploy/helm/values.yaml || true
git config user.email "ci@local" git config user.email "ci@local"
git config user.name "gitea-ci" git config user.name "gitea-ci"
if git diff --quiet deploy/helm/values.yaml; then
echo "No changes to commit"
exit 0
fi
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: