Skip to content

Commit b18ac3a

Browse files
committed
feat: retrieve version from package.json and pass as environment variable
1 parent 563ed6a commit b18ac3a

4 files changed

Lines changed: 20 additions & 4 deletions

File tree

.github/workflows/build-push.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ jobs:
2424
username: olabekkevold
2525
password: ${{ secrets.PAT }}
2626

27+
- name: Get version from package.json
28+
id: version
29+
run: |
30+
VERSION=$(jq -r '.version' ./labman/package.json)
31+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
32+
echo "Version: $VERSION"
33+
2734
- name: Determine image tag
2835
id: tag
2936
run: |
@@ -43,5 +50,9 @@ jobs:
4350
tags: |
4451
ghcr.io/olabekkevold/labmanager:${{ steps.tag.outputs.env_tag }}
4552
ghcr.io/olabekkevold/labmanager:${{ github.sha }}
46-
47-
53+
build-args: |
54+
NEXT_PUBLIC_VERSION=${{ steps.version.outputs.VERSION }}
55+
NEXT_PUBLIC_ENV=${{ steps.tag.outputs.env_tag }}
56+
57+
58+

labman/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ WORKDIR /app
2424
COPY --from=deps /app/node_modules ./node_modules
2525
COPY . .
2626

27+
ARG NEXT_PUBLIC_ENV
28+
ENV NEXT_PUBLIC_ENV=${NEXT_PUBLIC_ENV}
29+
30+
ARG NEXT_PUBLIC_VERSION
31+
ENV NEXT_PUBLIC_VERSION=${NEXT_PUBLIC_VERSION}
2732
# Next.js collects completely anonymous telemetry data about general usage.
2833
# Learn more here: https://nextjs.org/telemetry
2934
# Uncomment the following line in case you want to disable telemetry during the build.

labman/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "labman",
3-
"version": "0.1.0",
3+
"version": "1.0.0",
44
"type": "module",
55
"private": true,
66
"scripts": {

labman/src/app/(auth)/login/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default function Home() {
4242
</form>
4343
</div>
4444
</div>
45-
<p className={"text-gray-300 text-2xl mb-3 ml-3 fixed bottom-0"}>v1.0.0-test</p>
45+
<p className={"text-gray-300 text-2xl mb-3 ml-3 fixed bottom-0"}>{process.env.NEXT_PUBLIC_VERSION}</p>
4646
</>
4747

4848

0 commit comments

Comments
 (0)