Skip to content

Commit d299790

Browse files
feat: enhance Dockerfile to support GitHub token via secret mount and improve error handling
1 parent e63aa4b commit d299790

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

.github/workflows/container-build.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ jobs:
4646
file: container/Dockerfile
4747
push: true
4848
platforms: linux/amd64
49-
build-args: |
50-
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
49+
secrets: |
50+
# Optionally replace secrets.GITHUB_TOKEN with a PAT (store it under the same secret name
51+
# or adjust this mapping) to avoid 401 responses and heavy rate limiting when the pipeline
52+
# fetches metadata for thousands of modules.
53+
github_token=${{ secrets.GITHUB_TOKEN }}
5154
tags: ${{ steps.meta.outputs.image }}

container/Dockerfile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# syntax=docker/dockerfile:1.7
2+
13
FROM node:24-slim AS builder
24

35
RUN apt-get update \
@@ -8,12 +10,18 @@ WORKDIR /workspace
810

911
COPY . .
1012

11-
ARG GITHUB_TOKEN WIKI_FILE
12-
RUN <<EOF
13+
ARG WIKI_FILE
14+
RUN --mount=type=secret,id=github_token <<'EOF'
1315
set -e
1416
git config --global --add safe.directory /workspace
1517
git log -1
16-
export GITHUB_TOKEN="${GITHUB_TOKEN}"
18+
TOKEN_FILE="/run/secrets/github_token"
19+
if [ -f "$TOKEN_FILE" ]; then
20+
GITHUB_TOKEN_VALUE="$(cat "$TOKEN_FILE")"
21+
if [ -n "$GITHUB_TOKEN_VALUE" ]; then
22+
export GITHUB_TOKEN="$GITHUB_TOKEN_VALUE"
23+
fi
24+
fi
1725
npm clean-install
1826
node --run all
1927
EOF

cspell.config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"NOASSERTION",
4141
"omxplayer",
4242
"openweathermap",
43+
"pipefail",
4344
"ptrbld",
4445
"ratp",
4546
"refspecs",

0 commit comments

Comments
 (0)