Skip to content

Commit 2b5cc94

Browse files
fix: secure GITHUB_TOKEN handling in Docker build
Use BuildKit secrets instead of ARG to prevent token exposure
1 parent b55c9bb commit 2b5cc94

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

.github/workflows/container-build.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ jobs:
4646
file: container/Dockerfile
4747
push: true
4848
platforms: linux/amd64
49-
build-args: |
50-
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
49+
secrets: |
50+
github_token=${{ secrets.GITHUB_TOKEN }}
5151
tags: ${{ steps.meta.outputs.image }}

container/Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ WORKDIR /workspace
88

99
COPY . .
1010

11-
ARG GITHUB_TOKEN WIKI_FILE
12-
RUN <<EOF
11+
ARG WIKI_FILE
12+
RUN --mount=type=secret,id=github_token <<EOF
1313
set -e
1414
git config --global --add safe.directory /workspace
1515
git log -1
16-
export GITHUB_TOKEN="${GITHUB_TOKEN}"
16+
if [ -f /run/secrets/github_token ]; then
17+
export GITHUB_TOKEN="$(cat /run/secrets/github_token)"
18+
fi
1719
export NODE_OPTIONS="--experimental-strip-types"
1820
npm clean-install
1921
node --run all

0 commit comments

Comments
 (0)