Skip to content

Commit

Permalink
Make the workflow responsible for passing the full image tag(s) to th…
Browse files Browse the repository at this point in the history
…e 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.
  • Loading branch information
andrewn617 committed May 23, 2024
1 parent 4428368 commit 2e2bcb1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
6 changes: 1 addition & 5 deletions .github/actions/build-and-publish-image/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/publish-new-image-version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
2 changes: 1 addition & 1 deletion .github/workflows/publish-new-ruby-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

0 comments on commit 2e2bcb1

Please sign in to comment.