Github Actions如何依赖Go Mod 公有库

Golang版本

应用golang1.13以上的版本

GO mod依赖github 公有库的根本设置

  • 设置GOPRIVATE:export GOPRIVATE=github.com/xxx/common
  • 生成GitHub access token
  • 设置git 配置 git config --global url."https://xxx:${{ xxx.ACCESS_TOKEN }}@github.com".insteadOf "https://github.com"

设置了下面的三步之后,就能够失常的获取依赖了;

GitHub Actions设置

一个前提:咱们不想在GitHub 的actions中填写本人的access token明文
所以须要在repo中找到Settings-->Secrets中加以一个名为ACCESS_TOKEN的Secrets,当然这个名字能够本人定

  • 设置
  • 批改Actions代码

     - name: Run tests      shell: bash      run: |        export GO111MODULE=on        export GOPRIVATE=github.com/bytom/common        export GOPROXY=https://goproxy.cn        git config --global url."https://user_name:${{ secrets.ACCESS_TOKEN }}@github.com".insteadOf "https://github.com"        make ci        

设置完之后就能够失常的运作了