From e724416f23f6958ed63eaa1c77bf4606579f39f0 Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com.> Date: Tue, 26 Aug 2025 13:09:58 +0100 Subject: [PATCH] npm test --- .github/workflows/PR-Auto-Deploy-V2.yml | 15 +++++++++++++-- .github/workflows/deploy-on-v2-commit.yml | 17 +++++++++++++++-- docker/frontend/Dockerfile | 10 +++++++++- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/.github/workflows/PR-Auto-Deploy-V2.yml b/.github/workflows/PR-Auto-Deploy-V2.yml index dc35f4913..f88ce78b7 100644 --- a/.github/workflows/PR-Auto-Deploy-V2.yml +++ b/.github/workflows/PR-Auto-Deploy-V2.yml @@ -260,8 +260,8 @@ jobs: echo "Backend image needs to be built" fi - - name: Build and push V2 frontend image - if: steps.check-frontend.outputs.exists == 'false' + - name: Build and push V2 frontend image (with NPM token) + if: steps.check-frontend.outputs.exists == 'false' && secrets.NPM_TOKEN != '' uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 with: context: . @@ -273,6 +273,17 @@ jobs: secrets: | npmrc=//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} + - name: Build and push V2 frontend image (anonymous) + if: steps.check-frontend.outputs.exists == 'false' && secrets.NPM_TOKEN == '' + uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 + with: + context: . + file: ./docker/frontend/Dockerfile + push: true + tags: ${{ secrets.DOCKER_HUB_USERNAME }}/test:v2-frontend-${{ steps.commit-hashes.outputs.frontend_short }} + build-args: VERSION_TAG=v2-alpha + platforms: linux/amd64 + - name: Build and push V2 backend image if: steps.check-backend.outputs.exists == 'false' uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 diff --git a/.github/workflows/deploy-on-v2-commit.yml b/.github/workflows/deploy-on-v2-commit.yml index 78af03d7c..4712eb20e 100644 --- a/.github/workflows/deploy-on-v2-commit.yml +++ b/.github/workflows/deploy-on-v2-commit.yml @@ -91,8 +91,8 @@ jobs: username: ${{ secrets.DOCKER_HUB_USERNAME }} password: ${{ secrets.DOCKER_HUB_API }} - - name: Build and push frontend image - if: steps.check-frontend.outputs.exists == 'false' + - name: Build and push frontend image (with NPM token) + if: steps.check-frontend.outputs.exists == 'false' && secrets.NPM_TOKEN != '' uses: docker/build-push-action@v6 with: context: . @@ -105,6 +105,19 @@ jobs: platforms: linux/amd64 secrets: | npmrc=//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} + + - name: Build and push frontend image (anonymous) + if: steps.check-frontend.outputs.exists == 'false' && secrets.NPM_TOKEN == '' + uses: docker/build-push-action@v6 + with: + context: . + file: ./docker/frontend/Dockerfile + push: true + tags: | + ${{ secrets.DOCKER_HUB_USERNAME }}/test:v2-frontend-${{ steps.commit-hashes.outputs.frontend_short }} + ${{ secrets.DOCKER_HUB_USERNAME }}/test:v2-frontend-latest + build-args: VERSION_TAG=v2-alpha + platforms: linux/amd64 - name: Build and push backend image if: steps.check-backend.outputs.exists == 'false' diff --git a/docker/frontend/Dockerfile b/docker/frontend/Dockerfile index 4285dbfe3..35971f975 100644 --- a/docker/frontend/Dockerfile +++ b/docker/frontend/Dockerfile @@ -8,10 +8,14 @@ COPY frontend/package*.json ./ # Install dependencies (uses .npmrc secret if available, otherwise anonymous) RUN --mount=type=secret,id=npmrc \ + set -e && \ if [ -s /run/secrets/npmrc ]; then \ + echo "Using authenticated npm registry" && \ echo "$(cat /run/secrets/npmrc)" > /root/.npmrc; \ + else \ + echo "Using anonymous npm registry (no token provided)"; \ fi && \ - npm ci && \ + npm ci --loglevel=warn && \ rm -f /root/.npmrc # Copy source code @@ -19,8 +23,12 @@ COPY frontend . # Build the application (uses .npmrc secret if available, otherwise anonymous) RUN --mount=type=secret,id=npmrc \ + set -e && \ if [ -s /run/secrets/npmrc ]; then \ + echo "Using authenticated npm registry for build" && \ echo "$(cat /run/secrets/npmrc)" > /root/.npmrc; \ + else \ + echo "Using anonymous npm registry for build (no token provided)"; \ fi && \ npm run build && \ rm -f /root/.npmrc