From 042448f8bf66c46edfe51d2ac6e9860890dc06b2 Mon Sep 17 00:00:00 2001 From: Damyan Yordanov Date: Thu, 5 Oct 2023 12:20:37 +0200 Subject: [PATCH] Restore git global config `setup-git-redirect.sh` is needed for tests, because go needs SSH authentication, when downloading modules dependencies. The redirect script, though, does not revert the global changes done to the git config (in that case: SSH instead of HTTPS). The `checkout` action, on the other hand, needs the HTTPS for checkout, because the SSH key at the beginning of the action is no longer available, it was properly cleaned up in the `webfactory/ssh-agent` post clean up. Implementing workaround as in https://github.com/webfactory/ssh-agent/issues/184 --- .github/workflows/golangci-lint.yml | 5 +++++ .github/workflows/test.yml | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index a5d572d1..09875b1b 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -23,3 +23,8 @@ jobs: uses: golangci/golangci-lint-action@v3 with: version: v1.53.3 + - name: Restore git global config + if: always() + run: | + MATCH=$(grep -o 'git@.*github\.com:' ~/.gitconfig) + git config --global --remove-section url.${MATCH} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 957c16c2..7c4c06a9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -44,3 +44,8 @@ jobs: ssh-private-key: ${{ secrets.BOT_PRIVATE_KEY }} - run: ./hack/setup-git-redirect.sh - run: make test + - name: Restore git global config + if: always() + run: | + MATCH=$(grep -o 'git@.*github\.com:' ~/.gitconfig) + git config --global --remove-section url.${MATCH}