Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
276 views
in Technique[技术] by (71.8m points)

github-actions中无法访问私有仓库的问题

目前有一个golang开发的项目(私有仓库)在使用github-actions部署的时候,由于它依赖于另一个私有仓库(版本号v1.0.0),,所以涉及到一些权限问题。目前使用的是 https://github.com/actions/checkout actions,也同时指定了PAT token,但仍提示找不到依赖的版本号。

日志里可以看到依赖库是可以clone成功的,但在执行 go get -v -t -d 的时候,提示版本号未知。

- name: Set up Go 1.x

uses: actions/setup-go@v2

with:

go-version: ^1.13

id: go

  - name: 项目仓库
      uses: actions/checkout@v2
  
  - name: Get dependencies
    run: |
      go get -v -t -d ./...
      if [ -f Gopkg.toml ]; then
      curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
      dep ensure
      fi

错误

go: github.com/username/[email protected]: reading github.com/username/rpc-server/go.mod at revision v1.0.0: unknown revision v1.0.0

问题已经解决。
由于依赖于第三方的私有仓库,所以需要配置git config,参考的其它文章多写了一个符号,但在线下环境中手动执行是一切ok的,没有想到githbu actions环境中一直出现版本号错误。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

已解决了。

在设置git config的时候多写了一个/,正确的应该是下面的这种写法

- name: Get dependencies
      run: |
        go env -w GOPRIVATE="github.com/username"
        git config --global url."https://username:[email protected]".insteadOf "https://github.com"
        go get -v -t -d ./...

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...