Github Actions如何执行GO Mod 私有库
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/xxx/common export GOPROXY=https://goproxy.cn git config --global url."https://user_name:${{ secrets.ACCESS_TOKEN }}@github.com".insteadOf "https://github.com" make ci
设置完之后就可以正常的运作了
阅读 1.3k
0 条评论
得票最新