diff --git a/.github/workflows/build-image-prod.yaml b/.github/workflows/build-image-prod.yaml deleted file mode 100644 index bc58a0e..0000000 --- a/.github/workflows/build-image-prod.yaml +++ /dev/null @@ -1,40 +0,0 @@ -name: Docker Build and Push - Prod - -on: - workflow_dispatch: - push: - branches: ["prod"] - -permissions: - contents: read - packages: write - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Create tag name - run: echo "tag=prod-$(date +'%Y-%m-%dT%H-%M-%S')_$GITHUB_SHA" >> $GITHUB_ENV - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Log in to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push Docker image - uses: docker/build-push-action@v6 - with: - context: . - platforms: linux/arm64,linux/amd64 - push: true - tags: ghcr.io/nudgebee/nova:${{ env.tag }} - build-args: | - BUILDKIT_INLINE_CACHE=1 diff --git a/.github/workflows/build-image-dev.yaml b/.github/workflows/build-image.yaml similarity index 63% rename from .github/workflows/build-image-dev.yaml rename to .github/workflows/build-image.yaml index d91a99c..9ed147f 100644 --- a/.github/workflows/build-image-dev.yaml +++ b/.github/workflows/build-image.yaml @@ -1,9 +1,10 @@ -name: Docker Build and Push - Dev +name: Build and publish image on: workflow_dispatch: push: branches: ["main"] + tags: ["v*"] permissions: contents: read @@ -12,12 +13,17 @@ permissions: jobs: build: runs-on: ubuntu-latest - steps: - uses: actions/checkout@v4 - - name: Create tag name - run: echo "tag=dev-$(date +'%Y-%m-%dT%H-%M-%S')_$GITHUB_SHA" >> $GITHUB_ENV + - name: Resolve image tag + id: tag + run: | + if [[ "${{ github.ref_type }}" == "tag" ]]; then + echo "value=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT" + else + echo "value=$(date +'%Y-%m-%dT%H-%M-%S')_${GITHUB_SHA}" >> "$GITHUB_OUTPUT" + fi - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -35,6 +41,6 @@ jobs: context: . platforms: linux/arm64,linux/amd64 push: true - tags: ghcr.io/nudgebee/nova:${{ env.tag }} + tags: ghcr.io/nudgebee/nova:${{ steps.tag.outputs.value }} build-args: | BUILDKIT_INLINE_CACHE=1