-
Notifications
You must be signed in to change notification settings - Fork 0
use GIT_ACCESS_TOKEN instead of GH_PAT #80
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,8 +1,6 @@ | ||||||||||||||||||||||||||||||
| # Build the manager binary | ||||||||||||||||||||||||||||||
| FROM golang:1.24 AS builder | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ARG GH_TOKEN | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ARG PRIVATE_REPO_HOST=github.com/scality | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| ARG TARGETOS | ||||||||||||||||||||||||||||||
|
|
@@ -12,16 +10,19 @@ WORKDIR /workspace | |||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| RUN go env -w GOPRIVATE=${PRIVATE_REPO_HOST} | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| RUN if [ -z "$GH_TOKEN" ]; then echo "GH_TOKEN is missing"; exit 1; fi && \ | ||||||||||||||||||||||||||||||
| git config --global url."https://oauth2:${GH_TOKEN}@${PRIVATE_REPO_HOST}".insteadOf "https://${PRIVATE_REPO_HOST}" | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # Copy the Go Modules manifests | ||||||||||||||||||||||||||||||
| COPY go.mod go.mod | ||||||||||||||||||||||||||||||
| COPY go.sum go.sum | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # cache deps before building and copying source so that we don't need to re-download as much | ||||||||||||||||||||||||||||||
| # and so that source changes don't invalidate our downloaded layer | ||||||||||||||||||||||||||||||
| RUN go mod download | ||||||||||||||||||||||||||||||
| # Cache deps before building and copying source. Use BuildKit secret for GH_TOKEN so it | ||||||||||||||||||||||||||||||
| # never appears in build args or image history. Pass with: --secret id=gh_token,env=GH_TOKEN | ||||||||||||||||||||||||||||||
| RUN --mount=type=secret,id=gh_token \ | ||||||||||||||||||||||||||||||
| if [ -f /run/secrets/gh_token ] && [ -s /run/secrets/gh_token ]; then \ | ||||||||||||||||||||||||||||||
|
Comment on lines
+19
to
+20
|
||||||||||||||||||||||||||||||
| token=$(cat /run/secrets/gh_token); \ | ||||||||||||||||||||||||||||||
| git config --global url."https://oauth2:${token}@${PRIVATE_REPO_HOST}".insteadOf "https://${PRIVATE_REPO_HOST}"; \ | ||||||||||||||||||||||||||||||
| fi && \ | ||||||||||||||||||||||||||||||
|
Comment on lines
+20
to
+23
|
||||||||||||||||||||||||||||||
| if [ -f /run/secrets/gh_token ] && [ -s /run/secrets/gh_token ]; then \ | |
| token=$(cat /run/secrets/gh_token); \ | |
| git config --global url."https://oauth2:${token}@${PRIVATE_REPO_HOST}".insteadOf "https://${PRIVATE_REPO_HOST}"; \ | |
| fi && \ | |
| if [ ! -f /run/secrets/gh_token ]; then \ | |
| echo "error: /run/secrets/gh_token is required to download private Go modules from ${PRIVATE_REPO_HOST}" >&2; \ | |
| exit 1; \ | |
| fi; \ | |
| token=$(tr -d '\n' < /run/secrets/gh_token); \ | |
| if [ -z "$token" ]; then \ | |
| echo "error: /run/secrets/gh_token is empty; cannot authenticate to ${PRIVATE_REPO_HOST}" >&2; \ | |
| exit 1; \ | |
| fi; \ | |
| git config --global url."https://oauth2:${token}@${PRIVATE_REPO_HOST}".insteadOf "https://${PRIVATE_REPO_HOST}" && \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inline instructions still reference
GH_TOKEN/GH_TOKENenv, but this PR switches CI toGIT_ACCESS_TOKENand the mounted secret id isgh_token. Update this comment so local build instructions match the new secret name/source and don’t mislead users.