Skip to content

Commit c8b76fc

Browse files
authored
feat: GITHUB_TOKEN as build secret (IN-3193) (#363)
### TL;DR Added GitHub token as a build secret to the track update script. ### What changed? Added a new `BUILD_SECRETS` array to the `update_track.sh` script that includes the `GITHUB_TOKEN` as an environment variable secret. This secret is now passed to the `docker buildx build` command. Leaving the build arg in this phase as we move to deprecate it. ### Why make this change? This change allows the Docker build process to securely access GitHub resources that require authentication, such as private repositories or packages, without exposing the token in the build arguments or image layers. Using the `--secret` flag ensures the token is only available during build time and not persisted in the final image.
1 parent 032bf48 commit c8b76fc

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/scripts/track/update_track.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ if [[ $IMAGE_EXISTS == "false" || "$CIRCLE_BRANCH" == "master" || "$CIRCLE_BRANC
160160
--label "com.datadoghq.tags.git.repository_url=${CIRCLE_REPOSITORY_URL}"
161161
)
162162

163+
BUILD_SECRETS=(
164+
--secret "type=env,id=GITHUB_TOKEN"
165+
)
166+
163167
echo "BUILD_ARGS: ${BUILD_ARGS[*]}"
164168
docker buildx build \
165169
"${LEGACY_BUILD_ARGS[@]}" \
@@ -169,6 +173,7 @@ if [[ $IMAGE_EXISTS == "false" || "$CIRCLE_BRANCH" == "master" || "$CIRCLE_BRANC
169173
"${AWS_CREDENTIALS_ARG[@]}" \
170174
"${NPM_TOKEN_SECRET[@]}" \
171175
"${BUILD_ARGS[@]}" \
176+
"${BUILD_SECRETS[@]}" \
172177
"${OUTPUT_ARGS[@]}" \
173178
"${DATADOG_LABELS[@]}" \
174179
-f "$BUILD_CONTEXT/$DOCKERFILE" \

0 commit comments

Comments
 (0)