diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d334bb3..2394faf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,6 +7,8 @@ on: jobs: release: + # Only run on the original repository, not forks + if: ${{ github.repository_owner == 'varun-raj' }} runs-on: ubuntu-latest permissions: contents: write @@ -32,7 +34,7 @@ jobs: contents: read packages: write needs: release - if: needs.release.outputs.new-release-published == 'true' + if: always() && !failure() steps: - uses: actions/checkout@v3 - uses: docker/metadata-action@v5 @@ -42,7 +44,8 @@ jobs: images: | ghcr.io/${{ github.repository }} tags: | - type=semver,pattern={{major}}.{{minor}}.{{patch}} + type=raw,value=latest,enable=${{ github.repository_owner != 'varun-raj' || needs.release.outputs.new-release-published == 'true' }} + type=semver,pattern={{major}}.{{minor}}.{{patch}},enable=${{ github.repository_owner == 'varun-raj' && needs.release.outputs.new-release-published == 'true' }} - uses: docker/setup-buildx-action@v3 - uses: docker/login-action@v3 with: @@ -56,6 +59,9 @@ jobs: context: . platforms: linux/amd64,linux/arm64 push: true + tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max + build-args: | + VERSION=${{ needs.release.outputs.new-release-version || 'dev' }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 629fe2f..a295930 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,6 +20,11 @@ RUN npm run build # Production image, copy all the files and run next FROM node:18-alpine AS runner WORKDIR /app +# Define a build argument +ARG VERSION=dev + +# Set the build argument as an environment variable +ENV VERSION=$VERSION ENV NODE_ENV=production