diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index c3e8fa1857..58507831e9 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -42,8 +42,18 @@ jobs: - name: Configure git for public modules run: | - # Delete entire VCS cache to clear any stale remotes - rm -rf /root/go/pkg/mod/cache/vcs 2>/dev/null || true + # Update any cached VCS remotes from direct to public URL + for dir in /root/go/pkg/mod/cache/vcs/*/; do + if [ -d "$dir/.git" ] || [ -d "$dir/refs" ]; then + cd "$dir" + REMOTE=$(git remote get-url origin 2>/dev/null || echo "") + if echo "$REMOTE" | grep -q "direct.git.marketally.com"; then + NEW_REMOTE=$(echo "$REMOTE" | sed 's|direct.git.marketally.com|git.marketally.com|g') + echo "Updating $dir remote: $REMOTE -> $NEW_REMOTE" + git remote set-url origin "$NEW_REMOTE" || true + fi + fi + done git config --global url."https://git.marketally.com/".insteadOf "https://direct.git.marketally.com/" - name: Update vault dependency @@ -96,7 +106,9 @@ jobs: - name: Configure git for public modules run: | - rm -rf /root/go/pkg/mod/cache/vcs 2>/dev/null || true + for dir in /root/go/pkg/mod/cache/vcs/*/; do + [ -d "$dir" ] && cd "$dir" && git remote set-url origin "$(git remote get-url origin | sed 's|direct.git.marketally.com|git.marketally.com|g')" 2>/dev/null || true + done git config --global url."https://git.marketally.com/".insteadOf "https://direct.git.marketally.com/" - name: Update vault dependency @@ -156,7 +168,9 @@ jobs: - name: Configure git for public modules run: | - rm -rf /root/go/pkg/mod/cache/vcs 2>/dev/null || true + for dir in /root/go/pkg/mod/cache/vcs/*/; do + [ -d "$dir" ] && cd "$dir" && git remote set-url origin "$(git remote get-url origin | sed 's|direct.git.marketally.com|git.marketally.com|g')" 2>/dev/null || true + done git config --global url."https://git.marketally.com/".insteadOf "https://direct.git.marketally.com/" - name: Update vault dependency @@ -309,14 +323,24 @@ jobs: - name: Configure git for public modules (Unix) if: matrix.goos != 'windows' run: | - rm -rf /root/go/pkg/mod/cache/vcs 2>/dev/null || true + for dir in /root/go/pkg/mod/cache/vcs/*/; do + [ -d "$dir" ] && cd "$dir" && git remote set-url origin "$(git remote get-url origin | sed 's|direct.git.marketally.com|git.marketally.com|g')" 2>/dev/null || true + done git config --global url."https://git.marketally.com/".insteadOf "https://direct.git.marketally.com/" - name: Configure git for public modules (Windows) if: matrix.goos == 'windows' shell: pwsh run: | - Remove-Item -Path "$env:USERPROFILE\go\pkg\mod\cache\vcs" -Recurse -Force -ErrorAction SilentlyContinue + Get-ChildItem "$env:USERPROFILE\go\pkg\mod\cache\vcs" -Directory -ErrorAction SilentlyContinue | ForEach-Object { + Push-Location $_.FullName + $remote = git remote get-url origin 2>$null + if ($remote -like "*direct.git.marketally.com*") { + $newRemote = $remote -replace "direct.git.marketally.com", "git.marketally.com" + git remote set-url origin $newRemote 2>$null + } + Pop-Location + } git config --global url."https://git.marketally.com/".insteadOf "https://direct.git.marketally.com/" - name: Update vault dependency (Unix) @@ -576,7 +600,9 @@ jobs: - name: Configure git for public modules run: | - rm -rf /root/go/pkg/mod/cache/vcs 2>/dev/null || true + for dir in /root/go/pkg/mod/cache/vcs/*/; do + [ -d "$dir" ] && cd "$dir" && git remote set-url origin "$(git remote get-url origin | sed 's|direct.git.marketally.com|git.marketally.com|g')" 2>/dev/null || true + done git config --global url."https://git.marketally.com/".insteadOf "https://direct.git.marketally.com/" - name: Update vault dependency