Skip to content

Commit 7b79e93

Browse files
committed
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
1 parent 4b2aa43 commit 7b79e93

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

.github/workflows/build-and-publish-images.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
name: Build and Publish Images
22

33
on:
4-
workflow_dispatch:
4+
push:
5+
tags: [ 'ruby-*.*.*' ]
56

67
jobs:
78
build:
@@ -44,6 +45,9 @@ jobs:
4445
with:
4546
platforms: linux/amd64,linux/arm64
4647

48+
- name: Set Image version env variable
49+
run: echo "IMAGE_VERSION=$(echo ${{ github.ref_name }} | tr -d ruby-)" >> $GITHUB_ENV
50+
4751
- name: Login to GitHub Container Registry
4852
uses: docker/login-action@v2
4953
with:
@@ -58,7 +62,7 @@ jobs:
5862
BUILDX_NO_DEFAULT_ATTESTATIONS: true
5963
with:
6064
imageName: ghcr.io/rails/devcontainer/images/ruby
61-
imageTag: 0.3.0-${{ matrix.RUBY_VERSION }},${{ matrix.RUBY_VERSION }}
65+
imageTag: ${{ env.IMAGE_VERSION }}-${{ matrix.RUBY_VERSION }},${{ matrix.RUBY_VERSION }}
6266
subFolder: images/ruby
6367
push: always
6468
platform: linux/amd64,linux/arm64

0 commit comments

Comments
 (0)