Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reusable_go_lint_test: Support private repo authentication #8

Merged
merged 14 commits into from
Sep 1, 2024

Conversation

maiquanghiep
Copy link
Collaborator

@maiquanghiep maiquanghiep commented Aug 26, 2024

This PR adds go-private-repos-authentication input togo_lint_test and docker_pipeline workflow to allow Golang repos to use private modules.
If the input is enabled, it will change the git config to use PAT when downloading packages.
One important thing to note here: while it's recommended to set GOPRIVATE to control which modules the go command considers to be private and should therefore not use the proxy or checksum database (ref), I decided not to add the variable to support it so that the workflow's caller is cleaner. One example of that variable can be

      go-private-repos:
          description: 'Comma-separated list of private Go repositories'
          type: string
          default: 'github.com/babylonlabs-io/babylon-privat'

which can be used as below in the go_lint_test

      - name: Configure Private Module Access
        if: ${{ inputs.go-private-repos != '' }}
        run: |
          go env -w GOPRIVATE=${{ inputs.go-private-repos }} # inputs.go-private-repos is used here
          git config --global url."https://${{ secrets.GO_PRIVATE_TOKEN }}@github.com/".insteadOf "https://github.com/"

To make the above consideration work, the GOPROXY='https://proxy.golang.org,direct/ env must be set, which is true as it's the default value (e.g You can check the Print Go environment step of this workflow run).

Also https://docs.docker.com/build/ci/github-actions/secrets was referred to mount secrets to docker which is useful when reviewing docker_pipeline.
Example of workflow caller PR babylonlabs-io/finality-provider#43

Copy link
Member

@filippos47 filippos47 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tidy PR as usual, thanks Hiep!

@maiquanghiep maiquanghiep merged commit 23fb5e1 into main Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants