From 2e2bcb14538dcc4f9c604ce333e893ade3141349 Mon Sep 17 00:00:00 2001 From: Andrew Novoselac Date: Thu, 23 May 2024 07:40:48 -0400 Subject: [PATCH] Make the workflow responsible for passing the full image tag(s) to the build and publish action This way, when we publish images for older versions of the image, we do not overwrite the latest tag. For example: publishing 1.0.0-3.1.5 should not push an image to tag 3.1.5, just 1.0.0-3.1.5. --- .github/actions/build-and-publish-image/action.yml | 6 +----- .github/workflows/publish-new-image-version.yaml | 7 ++++++- .github/workflows/publish-new-ruby-versions.yml | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/actions/build-and-publish-image/action.yml b/.github/actions/build-and-publish-image/action.yml index 07fd369..e969660 100644 --- a/.github/actions/build-and-publish-image/action.yml +++ b/.github/actions/build-and-publish-image/action.yml @@ -29,10 +29,6 @@ runs: with: platforms: linux/amd64,linux/arm64 - - name: Set Image version env variable - run: echo "IMAGE_VERSION=$(echo ${{ inputs.image_tag }} | tr -d ruby-)" >> $GITHUB_ENV - shell: bash - - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: @@ -47,7 +43,7 @@ runs: BUILDX_NO_DEFAULT_ATTESTATIONS: true with: imageName: ghcr.io/rails/devcontainer/images/ruby - imageTag: ${{ env.IMAGE_VERSION }}-${{ inputs.ruby_version }},${{ inputs.ruby_version }} + imageTag: ${{ inputs.image_tag }} subFolder: images/ruby push: always platform: linux/amd64,linux/arm64 diff --git a/.github/workflows/publish-new-image-version.yaml b/.github/workflows/publish-new-image-version.yaml index 057f64b..49375f6 100644 --- a/.github/workflows/publish-new-image-version.yaml +++ b/.github/workflows/publish-new-image-version.yaml @@ -24,10 +24,15 @@ jobs: - name: Checkout (GitHub) uses: actions/checkout@v4 + + - name: Set Image version env variable + run: echo "IMAGE_VERSION=$(echo ${{ inputs.image_tag }} | tr -d ruby-)" >> $GITHUB_ENV + shell: bash + - name: Build and Publish Image uses: ./.github/actions/build-and-publish-image with: ruby_version: ${{ matrix.RUBY_VERSION }} - image_tag: ${{ github.ref_name }} + image_tag: ${{ env.IMAGE_VERSION }}-${{ matrix.RUBY_VERSION}},${{ matrix.RUBY_VERSION}} gh_token: ${{ secrets.GITHUB_TOKEN }} repository_owner: ${{ github.repository_owner }} diff --git a/.github/workflows/publish-new-ruby-versions.yml b/.github/workflows/publish-new-ruby-versions.yml index 6bfd1a9..4af8baf 100644 --- a/.github/workflows/publish-new-ruby-versions.yml +++ b/.github/workflows/publish-new-ruby-versions.yml @@ -34,6 +34,6 @@ jobs: uses: ./.github/actions/build-and-publish-image with: ruby_version: ${{ matrix.RUBY_VERSION }} - image_tag: ${{ matrix.IMAGE_VERSION }} + image_tag: ${{ matrix.IMAGE_VERSION }}-${{ matrix.RUBY_VERSION }} gh_token: ${{ secrets.GITHUB_TOKEN }} repository_owner: ${{ github.repository_owner }}