Skip to content

Commit 5589931

Browse files
vaibhavGadreCopilot
andcommitted
CHEF-33431: delegate platform-ui docker build to build-docker.sh
Replace inline Strategy 0 docker build block with a call to the repo's own build-docker.sh script. The script is now fully self-contained: - Submodule checkout using GITHUB_TOKEN - NPM_AZURE_KEY written to .npmrc.tmp as a BuildKit secret - docker buildx build --load, tagged platform-ui:local Removes the need to duplicate npm secret / submodule logic in the common workflow. Only GITHUB_TOKEN, NPM_AZURE_KEY, BRANCH_NAME, GIT_SHA, APP_VERSION and LOCALES are passed as env vars to the script. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 0748f20 commit 5589931

2 files changed

Lines changed: 24 additions & 36 deletions

File tree

.github/workflows/build-docker-image.yml

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@ jobs:
5959
id: build-image
6060
env:
6161
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
62-
# WARNING: This workflow accesses a non-default secret. Ensure this secret is
63-
# required and that it is stored securely in the repository or organization settings.
64-
NPM_AZURE_KEY: ${{ secrets.NPM_AZURE_KEY }}
6562
run: |
6663
if [ ! -f "Dockerfile" ]; then
6764
echo "❌ No Dockerfile found - cannot build"
@@ -71,22 +68,19 @@ jobs:
7168
echo "Building Docker image..."
7269
REPO_NAME=$(basename $(pwd))
7370
74-
# Strategy 0: platform-ui - build with NPM Azure Key via buildx secret
71+
# Strategy 0: platform-ui — delegate entirely to build-docker.sh which handles
72+
# submodule checkout (PAT), NPM Azure Key secret, and docker buildx build.
7573
if [ "${{ github.event.repository.name }}" = "platform-ui" ]; then
76-
echo "Detected platform-ui - building with NPM Azure Key secret"
77-
trap 'rm -f .npmrc.tmp' EXIT
78-
printf '%s' "$NPM_AZURE_KEY" > .npmrc.tmp
79-
docker buildx create --use
80-
docker buildx build \
81-
--secret id=npmrc,src=.npmrc.tmp \
82-
--load \
83-
--platform linux/amd64 \
84-
--build-arg GITHUB_TOKEN="$GITHUB_TOKEN" \
85-
--build-arg GIT_SHA="${{ github.sha }}" \
86-
--build-arg APP_VERSION="${{ github.ref_name }}" \
87-
--build-arg DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
88-
-t "${REPO_NAME}:latest" .
89-
IMAGES="${REPO_NAME}:latest"
74+
echo "Detected platform-ui - delegating to build-docker.sh"
75+
chmod +x build-docker.sh
76+
GITHUB_TOKEN="${{ secrets.GH_TOKEN }}" \
77+
NPM_AZURE_KEY="${{ secrets.NPM_AZURE_KEY }}" \
78+
BRANCH_NAME="${{ github.head_ref || github.ref_name }}" \
79+
GIT_SHA="${{ github.sha }}" \
80+
APP_VERSION="${{ github.ref_name }}" \
81+
LOCALES="en" \
82+
./build-docker.sh
83+
IMAGES="platform-ui:local"
9084
9185
# Strategy 1: Check for build-docker.sh script (e.g., dsm-erchef)
9286
elif [ -f "build-docker.sh" ]; then

.github/workflows/grype.yml

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,6 @@ jobs:
9797
if: ${{ inputs.prebuilt-image-artifact == '' }}
9898
env:
9999
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
100-
# WARNING: This workflow accesses a non-default secret. Ensure this secret is
101-
# required and that it is stored securely in the repository or organization settings.
102-
NPM_AZURE_KEY: ${{ secrets.NPM_AZURE_KEY }}
103100
run: |
104101
if [ ! -f "Dockerfile" ]; then
105102
echo "❌ No Dockerfile found - this workflow requires a Dockerfile to scan Docker image"
@@ -109,22 +106,19 @@ jobs:
109106
echo "Building Docker image..."
110107
REPO_NAME=$(basename $(pwd))
111108
112-
# Strategy 0: platform-ui - build with NPM Azure Key via buildx secret
109+
# Strategy 0: platform-ui — delegate entirely to build-docker.sh which handles
110+
# submodule checkout (PAT), NPM Azure Key secret, and docker buildx build.
113111
if [ "${{ github.event.repository.name }}" = "platform-ui" ]; then
114-
echo "Detected platform-ui - building with NPM Azure Key secret"
115-
trap 'rm -f .npmrc.tmp' EXIT
116-
printf '%s' "$NPM_AZURE_KEY" > .npmrc.tmp
117-
docker buildx create --use
118-
docker buildx build \
119-
--secret id=npmrc,src=.npmrc.tmp \
120-
--load \
121-
--platform linux/amd64 \
122-
--build-arg GITHUB_TOKEN="$GITHUB_TOKEN" \
123-
--build-arg GIT_SHA="${{ github.sha }}" \
124-
--build-arg APP_VERSION="${{ github.ref_name }}" \
125-
--build-arg DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
126-
-t "${REPO_NAME}:latest" .
127-
IMAGES="${REPO_NAME}:latest"
112+
echo "Detected platform-ui - delegating to build-docker.sh"
113+
chmod +x build-docker.sh
114+
GITHUB_TOKEN="${{ secrets.GH_TOKEN }}" \
115+
NPM_AZURE_KEY="${{ secrets.NPM_AZURE_KEY }}" \
116+
BRANCH_NAME="${{ github.head_ref || github.ref_name }}" \
117+
GIT_SHA="${{ github.sha }}" \
118+
APP_VERSION="${{ github.ref_name }}" \
119+
LOCALES="en" \
120+
./build-docker.sh
121+
IMAGES="platform-ui:local"
128122
129123
# Strategy 1: Check for build-docker.sh script (e.g., dsm-erchef)
130124
elif [ -f "build-docker.sh" ]; then

0 commit comments

Comments
 (0)