diff --git a/.github/workflows/build_image.yml b/.github/workflows/build_image.yml index 232b92a..b13a8d2 100644 --- a/.github/workflows/build_image.yml +++ b/.github/workflows/build_image.yml @@ -108,6 +108,11 @@ jobs: type=ref,event=tag type=sha,format=short,prefix= + # generate frontend build date in utc + - name: Generate frontend build date + id: frontend_build_meta + run: echo "build_date=$(date -u +'%Y/%m/%d UTC')" >> "$GITHUB_OUTPUT" + # build and push frontend docker image with version argument - name: Build Frontend Docker image uses: docker/build-push-action@v5 @@ -119,6 +124,7 @@ jobs: platforms: linux/amd64 build-args: | VERSION=${{ github.ref_type == 'tag' && github.ref_name || '' }} + BUILD_DATE=${{ steps.frontend_build_meta.outputs.build_date }} update_helm_values: runs-on: ubuntu-latest diff --git a/frontend/Dockerfile b/frontend/Dockerfile index d8f1980..94a1b2e 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -25,12 +25,15 @@ ENV NODE_ENV=production # accepts version argument to override package.json version ARG VERSION="" +# accepts build date argument to set package.json build metadata +ARG BUILD_DATE="" + COPY --from=deps /app/node_modules ./node_modules COPY . . -# update package.json version if VERSION arg is provided -RUN if [ -n "$VERSION" ]; then \ - node -e "const pkg = require('./package.json'); pkg.version = '$VERSION'; require('fs').writeFileSync('./package.json', JSON.stringify(pkg, null, 2))"; \ +# update package.json build metadata when build args are provided +RUN if [ -n "$VERSION" ] || [ -n "$BUILD_DATE" ]; then \ + VERSION="$VERSION" BUILD_DATE="$BUILD_DATE" node -e "const fs = require('fs'); const pkg = require('./package.json'); const version = process.env.VERSION; const buildDate = process.env.BUILD_DATE; if (version) pkg.version = version; if (buildDate) pkg.buildDate = buildDate; fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2) + '\\n')"; \ fi EXPOSE 3000 diff --git a/frontend/package.json b/frontend/package.json index 40a47ae..9c6dc7f 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,7 @@ { "name": "linux-do-cdk", "version": "1.2.3", + "buildDate": "2026-01-01T00:00:00Z", "private": true, "scripts": { "dev": "next dev --turbopack",