Skip to content

Commit d1eeec5

Browse files
committed
feat: add version and commit info to footer
- Create Footer component with version, commit hash, and build time display - Update layout to include footer with proper flex layout - Configure CI to inject build metadata as environment variables - Add branch name display for non-production environments - Include comprehensive test coverage for Footer component - Extract version from package.json and add branch suffix for non-main branches - Show short commit hash (7 chars) and formatted build date - Highlight non-production branches with orange color - Gracefully handle missing environment variables with defaults
1 parent dd051c1 commit d1eeec5

File tree

6 files changed

+20685
-20422
lines changed

6 files changed

+20685
-20422
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,28 @@ Auto-updated by GitHub Actions after successful test run
276276
run: npm ci
277277

278278
- name: Build application
279-
run: npm run build
279+
env:
280+
NEXT_PUBLIC_COMMIT_HASH: ${{ github.sha }}
281+
NEXT_PUBLIC_BUILD_TIME: ${{ github.event.head_commit.timestamp }}
282+
NEXT_PUBLIC_BRANCH: ${{ github.ref_name }}
283+
run: |
284+
# Get version from package.json
285+
VERSION=$(node -p "require('./package.json').version")
286+
287+
# Add branch suffix for non-main branches
288+
if [ "${{ github.ref_name }}" != "main" ]; then
289+
export NEXT_PUBLIC_APP_VERSION="${VERSION}-${{ github.ref_name }}"
290+
else
291+
export NEXT_PUBLIC_APP_VERSION="${VERSION}"
292+
fi
293+
294+
echo "Building with version info:"
295+
echo " Version: $NEXT_PUBLIC_APP_VERSION"
296+
echo " Commit: $NEXT_PUBLIC_COMMIT_HASH"
297+
echo " Build Time: $NEXT_PUBLIC_BUILD_TIME"
298+
echo " Branch: $NEXT_PUBLIC_BRANCH"
299+
300+
npm run build
280301
281302
- name: Test static export
282303
run: |

next.config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ const nextConfig = {
3636
// Environment variables for static export
3737
env: {
3838
NEXT_PUBLIC_APP_NAME: 'BrainPatch',
39-
NEXT_PUBLIC_APP_VERSION: process.env.npm_package_version || '0.1.0',
39+
NEXT_PUBLIC_APP_VERSION:
40+
process.env.NEXT_PUBLIC_APP_VERSION || process.env.npm_package_version || 'dev',
41+
NEXT_PUBLIC_COMMIT_HASH: process.env.NEXT_PUBLIC_COMMIT_HASH || 'unknown',
42+
NEXT_PUBLIC_BUILD_TIME: process.env.NEXT_PUBLIC_BUILD_TIME || new Date().toISOString(),
43+
NEXT_PUBLIC_BRANCH: process.env.NEXT_PUBLIC_BRANCH || 'local',
4044
},
4145
};
4246

0 commit comments

Comments
 (0)