npm login

This commit is contained in:
Anthony Stirling 2025-08-26 11:55:26 +01:00
parent 95b3e22229
commit 4331bc44e3
6 changed files with 50 additions and 4 deletions

View File

@ -260,6 +260,15 @@ jobs:
echo "Backend image needs to be built"
fi
- name: Create .npmrc for Docker build
if: steps.check-frontend.outputs.exists == 'false'
run: |
if [ "${{ secrets.NPM_TOKEN }}" != "" ]; then
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > /tmp/.npmrc
else
touch /tmp/.npmrc
fi
- name: Build and push V2 frontend image
if: steps.check-frontend.outputs.exists == 'false'
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
@ -270,6 +279,8 @@ jobs:
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/test:v2-frontend-${{ steps.commit-hashes.outputs.frontend_short }}
build-args: VERSION_TAG=v2-alpha
platforms: linux/amd64
secrets: |
npmrc=/tmp/.npmrc
- name: Build and push V2 backend image
if: steps.check-backend.outputs.exists == 'false'

View File

@ -143,14 +143,21 @@ jobs:
uses: actions/setup-node@v4.1.0
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install frontend dependencies
run: cd frontend && npm ci
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Build frontend
run: cd frontend && npm run build
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Run frontend tests
run: cd frontend && npm run test -- --run
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Upload frontend build artifacts
uses: actions/upload-artifact@v4.6.2
with:

View File

@ -91,6 +91,15 @@ jobs:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_API }}
- name: Create .npmrc for Docker build
if: steps.check-frontend.outputs.exists == 'false'
run: |
if [ "${{ secrets.NPM_TOKEN }}" != "" ]; then
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > /tmp/.npmrc
else
touch /tmp/.npmrc
fi
- name: Build and push frontend image
if: steps.check-frontend.outputs.exists == 'false'
uses: docker/build-push-action@v6
@ -103,6 +112,8 @@ jobs:
${{ secrets.DOCKER_HUB_USERNAME }}/test:v2-frontend-latest
build-args: VERSION_TAG=v2-alpha
platforms: linux/amd64
secrets: |
npmrc=/tmp/.npmrc
- name: Build and push backend image
if: steps.check-backend.outputs.exists == 'false'

View File

@ -48,16 +48,21 @@ jobs:
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install frontend dependencies
working-directory: frontend
run: npm ci
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Generate frontend license report
working-directory: frontend
run: npm run generate-licenses
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Check for license warnings
run: |

View File

@ -131,6 +131,7 @@ jobs:
- name: Set up Node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
- name: Run TestDriver.ai
@ -147,6 +148,7 @@ jobs:
1. /run testing/testdriver/test.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
FORCE_COLOR: "3"
cleanup:

View File

@ -6,14 +6,24 @@ WORKDIR /app
# Copy package files
COPY frontend/package*.json ./
# Install dependencies
RUN npm ci
# Install dependencies (uses .npmrc secret if available, otherwise anonymous)
RUN --mount=type=secret,id=npmrc,target=/tmp/.npmrc \
if [ -s /tmp/.npmrc ]; then \
cp /tmp/.npmrc /root/.npmrc; \
fi && \
npm ci && \
rm -f /root/.npmrc
# Copy source code
COPY frontend .
# Build the application
RUN npm run build
# Build the application (uses .npmrc secret if available, otherwise anonymous)
RUN --mount=type=secret,id=npmrc,target=/tmp/.npmrc \
if [ -s /tmp/.npmrc ]; then \
cp /tmp/.npmrc /root/.npmrc; \
fi && \
npm run build && \
rm -f /root/.npmrc
# Production stage
FROM nginx:alpine