php小編草在進行mod tidy時遇到了問題,嘗試透過ssh從內部倉庫進行操作卻失敗了。這種情況可能會導致程式碼倉庫的混亂,影響開發流程和專案的穩定性。在解決這個問題之前,我們需要了解失敗的原因和可能的解決方法,以確保程式碼倉庫的健康運作。接下來,我們將詳細探討如何解決這個問題。
使用內部 github 儲存庫時,我無法 go mod tidy
。 ssh 驗證似乎可以單獨工作(請參見下面的日誌),但是 go mod tidy
會命中內部儲存庫並拋出
[email protected]: permission denied (publickey). fatal: could not read from remote repository. please make sure you have the correct access rights and the repository exists.
來自我的 github 操作
steps: # checks-out the repository under $github_workspace, so the job can access it - uses: actions/checkout@v3 # set up go - name: set up go uses: actions/setup-go@v4 with: go-version: 1.20.2 cache: false - name: add private key to ssh agent env: private_key: ${{ secrets.shared_deploy_private_key }} run: | echo "${{ env.private_key }}" > key.pem chmod 600 key.pem eval "$(ssh-agent -s)" ssh-add key.pem ssh-add -l -e sha256 ssh -t [email protected] 2>&1 || true ### tests ssh auth # install dependencies - name: install dependencies run: | git config --global url."[email protected]:".insteadof "https://github.com/" go clean -modcache go env -w goprivate=github.com/my-org/* go env -w gonoproxy=github.com/my-org/* go env go mod tidy
登入新增私鑰
agent pid 1766 identity added: key.pem (_redacted_) 3072 sha256:_redacted_ _redacted_ (rsa) hi my-org/observability-go! you've successfully authenticated, but github does not provide shell access.
記錄安裝依賴項
go: downloading github.com/pmezard/go-difflib v1.0.0 go: downloading github.com/mattn/go-isatty v0.0.17 go: downloading golang.org/x/sync v0.1.0 github.com/my-org/clan-service/cmd/clanservice imports github.com/my-org/observability-go/logging: github.com/my-org/[email protected]: invalid version: git ls-remote -q origin in /home/runner/go/pkg/mod/cache/vcs/d0c7f50097d6054d27fc7949420737cdb6036d1246584bb05f13c6fe75577be2: exit status 128: [email protected]: permission denied (publickey). fatal: could not read from remote repository. please make sure you have the correct access rights and the repository exists.
go env
的輸出
GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/home/runner/.cache/go-build" GOENV="/home/runner/.config/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/home/runner/go/pkg/mod" GONOPROXY="github.com/my-org/*" GONOSUMDB="github.com/my-org/*" GOOS="linux" GOPATH="/home/runner/go" GOPRIVATE="github.com/my-org/*" GOPROXY="https://proxy.golang.org,direct" GOROOT="/opt/hostedtoolcache/go/1.20.2/x64" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/opt/hostedtoolcache/go/1.20.2/x64/pkg/tool/linux_amd64" GOVCS="" GOVERSION="go1.20.2" GCCGO="gccgo" GOAMD64="v1" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/home/runner/work/clan-service/clan-service/go.mod" GOWORK="" CGO_CFLAGS="-O2 -g" CGO_CPPFLAGS="" CGO_CXXFLAGS="-O2 -g" CGO_FFLAGS="-O2 -g" CGO_LDFLAGS="-O2 -g" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build4021260014=/tmp/go-build -gno-record-gcc-switches"
我錯過了什麼?我怎樣才能做到這一點?
每個步驟都在單獨的進程中運行,因此修改當前進程範圍的環境的操作將不會「生存」到下一步。
例如:
您需要在「安裝依賴項」步驟中重新執行 eval "$(ssh-agent -s)"
,以便正確設定環境以與您的 ssh 代理程式通訊。
以上是透過 ssh 從內部倉庫進行 mod tidy 失敗的詳細內容。更多資訊請關注PHP中文網其他相關文章!