diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml index a279f1e..b98d99c 100644 --- a/.github/workflows/build-push.yml +++ b/.github/workflows/build-push.yml @@ -14,6 +14,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v5 + with: + ref: ${{ github.event.workflow_run.head_sha }} - name: Log in to container registry uses: docker/login-action@v3 @@ -22,15 +24,23 @@ jobs: username: olabekkevold password: ${{ secrets.PAT }} + - name: Get version from package.json + id: version + run: | + VERSION=$(jq -r '.version' ./labman/package.json) + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT + echo "Version: $VERSION" + - name: Determine image tag id: tag run: | - REF="${{ github.ref }}" - if [ "$REF" = "refs/heads/main" ]; then + BRANCH="${{ github.event.workflow_run.head_branch }}" + if [ "$BRANCH" = "main" ]; then echo "env_tag=latest" >> $GITHUB_OUTPUT else echo "env_tag=test" >> $GITHUB_OUTPUT fi + echo "Image tag: ${{ steps.tag.outputs.env_tag }}" - name: Build and push Docker image uses: docker/build-push-action@v6 @@ -40,5 +50,9 @@ jobs: tags: | ghcr.io/olabekkevold/labmanager:${{ steps.tag.outputs.env_tag }} ghcr.io/olabekkevold/labmanager:${{ github.sha }} - - + build-args: | + NEXT_PUBLIC_VERSION=${{ steps.version.outputs.VERSION }} + NEXT_PUBLIC_ENV=${{ steps.tag.outputs.env_tag }} + + + diff --git a/labman/Dockerfile b/labman/Dockerfile index 901cabe..1a3d077 100644 --- a/labman/Dockerfile +++ b/labman/Dockerfile @@ -24,6 +24,11 @@ WORKDIR /app COPY --from=deps /app/node_modules ./node_modules COPY . . +ARG NEXT_PUBLIC_ENV +ENV NEXT_PUBLIC_ENV=${NEXT_PUBLIC_ENV} + +ARG NEXT_PUBLIC_VERSION +ENV NEXT_PUBLIC_VERSION=${NEXT_PUBLIC_VERSION} # Next.js collects completely anonymous telemetry data about general usage. # Learn more here: https://nextjs.org/telemetry # Uncomment the following line in case you want to disable telemetry during the build. diff --git a/labman/package.json b/labman/package.json index 0389254..26ad31c 100644 --- a/labman/package.json +++ b/labman/package.json @@ -1,6 +1,6 @@ { "name": "labman", - "version": "0.1.0", + "version": "1.0.0", "type": "module", "private": true, "scripts": { diff --git a/labman/src/app/(auth)/login/page.tsx b/labman/src/app/(auth)/login/page.tsx index e6b1b15..e0d1443 100644 --- a/labman/src/app/(auth)/login/page.tsx +++ b/labman/src/app/(auth)/login/page.tsx @@ -8,6 +8,9 @@ export default function Home() { const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); + const version = process.env.NEXT_PUBLIC_VERSION; + const env = process.env.NEXT_PUBLIC_ENV; + async function handleSubmit(e: React.FormEvent) { e.preventDefault(); const res = await fetch("/api/login", { @@ -42,7 +45,7 @@ export default function Home() { -

v1.0.0

+

{version}-{env}