From 7b79e934ed868fac8a61b57f7069c35322b490dc Mon Sep 17 00:00:00 2001 From: Andrew Novoselac Date: Wed, 27 Mar 2024 12:21:51 -0400 Subject: [PATCH] Improve the workflow for publishing images - Only run this workflow when we push a new image tag - Get the image version from the tag instead of hardcoding it --- .github/workflows/build-and-publish-images.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-publish-images.yaml b/.github/workflows/build-and-publish-images.yaml index 88dd2db..b7e84fc 100644 --- a/.github/workflows/build-and-publish-images.yaml +++ b/.github/workflows/build-and-publish-images.yaml @@ -1,7 +1,8 @@ name: Build and Publish Images on: - workflow_dispatch: + push: + tags: [ 'ruby-*.*.*' ] jobs: build: @@ -44,6 +45,9 @@ jobs: with: platforms: linux/amd64,linux/arm64 + - name: Set Image version env variable + run: echo "IMAGE_VERSION=$(echo ${{ github.ref_name }} | tr -d ruby-)" >> $GITHUB_ENV + - name: Login to GitHub Container Registry uses: docker/login-action@v2 with: @@ -58,7 +62,7 @@ jobs: BUILDX_NO_DEFAULT_ATTESTATIONS: true with: imageName: ghcr.io/rails/devcontainer/images/ruby - imageTag: 0.3.0-${{ matrix.RUBY_VERSION }},${{ matrix.RUBY_VERSION }} + imageTag: ${{ env.IMAGE_VERSION }}-${{ matrix.RUBY_VERSION }},${{ matrix.RUBY_VERSION }} subFolder: images/ruby push: always platform: linux/amd64,linux/arm64 \ No newline at end of file