diff --git a/.github/workflows/build_image.yml b/.github/workflows/build_image.yml index d8df8e8..47c0c96 100644 --- a/.github/workflows/build_image.yml +++ b/.github/workflows/build_image.yml @@ -115,6 +115,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 @@ -126,6 +131,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-24.04 diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 5975dab..98cbfca 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -24,12 +24,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 1a7ac32..1e0d46b 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,7 @@ { "name": "linux-do-credit", "version": "1.0.0", + "buildDate": "2026-01-01T00:00:00Z", "private": true, "scripts": { "dev": "next dev --turbopack",