File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed
Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -85,12 +85,13 @@ jobs:
8585 cache-from : type=gha
8686 cache-to : type=gha,mode=max
8787 build-args : |
88- GH_TOKEN=${{ secrets.GIT_ACCESS_TOKEN }}
8988 PRIVATE_REPO_HOST=github.com/scality
9089 BUILD_DATE=${{ fromJson(steps.meta.outputs.json)['org.opencontainers.image.created'] }}
9190 GIT_COMMIT=${{ github.sha }}
9291 SOURCE_DATE_EPOCH=${{ env.SOURCE_DATE_EPOCH }}
9392 VERSION=${{ inputs.version || github.sha }}
93+ secrets : |
94+ gh_token=${{ secrets.GIT_ACCESS_TOKEN }}
9495
9596 - name : Generate GitHub SLSA provenance
9697 uses : actions/attest-build-provenance@v1
Original file line number Diff line number Diff line change 11# Build the manager binary
22FROM golang:1.24 AS builder
33
4- ARG GH_TOKEN
5-
64ARG PRIVATE_REPO_HOST=github.com/scality
75
86ARG TARGETOS
@@ -12,16 +10,19 @@ WORKDIR /workspace
1210
1311RUN go env -w GOPRIVATE=${PRIVATE_REPO_HOST}
1412
15- RUN if [ -z "$GH_TOKEN" ]; then echo "GH_TOKEN is missing" ; exit 1; fi && \
16- git config --global url."https://oauth2:${GH_TOKEN}@${PRIVATE_REPO_HOST}" .insteadOf "https://${PRIVATE_REPO_HOST}"
17-
1813# Copy the Go Modules manifests
1914COPY go.mod go.mod
2015COPY go.sum go.sum
2116
22- # cache deps before building and copying source so that we don't need to re-download as much
23- # and so that source changes don't invalidate our downloaded layer
24- RUN go mod download
17+ # Cache deps before building and copying source. Use BuildKit secret for GH_TOKEN so it
18+ # never appears in build args or image history. Pass with: --secret id=gh_token,env=GH_TOKEN
19+ RUN --mount=type=secret,id=gh_token \
20+ if [ -f /run/secrets/gh_token ] && [ -s /run/secrets/gh_token ]; then \
21+ token=$(cat /run/secrets/gh_token); \
22+ git config --global url."https://oauth2:${token}@${PRIVATE_REPO_HOST}" .insteadOf "https://${PRIVATE_REPO_HOST}" ; \
23+ fi && \
24+ go mod download && \
25+ rm -f /root/.gitconfig
2526
2627# Copy the go source
2728COPY cmd/main.go cmd/main.go
You can’t perform that action at this time.
0 commit comments