Skip to content

Commit 7a679f9

Browse files
committed
Remove duplicated code from the publish image actions
1 parent 9590cc4 commit 7a679f9

3 files changed

Lines changed: 95 additions & 94 deletions

File tree

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Publish Images Reusable
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
ruby_versions_json:
7+
required: true
8+
type: string
9+
description: JSON array of Ruby versions
10+
image_versions_json:
11+
required: true
12+
type: string
13+
description: JSON array of image tags
14+
repository_owner:
15+
required: true
16+
type: string
17+
description: Repository owner for GHCR login
18+
secrets:
19+
gh_token:
20+
required: true
21+
22+
defaults:
23+
run:
24+
shell: bash
25+
26+
jobs:
27+
build:
28+
name: Build Images
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
RUBY_VERSION: ${{ fromJSON(inputs.ruby_versions_json) }}
33+
IMAGE_VERSION: ${{ fromJSON(inputs.image_versions_json) }}
34+
TARGET:
35+
- RUNNER: ubuntu-24.04
36+
BUILD_PLATFORM: linux/amd64
37+
PLATFORM_SUFFIX: amd64
38+
- RUNNER: ubuntu-24.04-arm
39+
BUILD_PLATFORM: linux/arm64
40+
PLATFORM_SUFFIX: arm64
41+
42+
runs-on: ${{ matrix.TARGET.RUNNER }}
43+
permissions:
44+
contents: read
45+
packages: write
46+
steps:
47+
- name: Build and Publish Image
48+
uses: ./.github/actions/build-and-publish-image
49+
with:
50+
ruby_version: ${{ matrix.RUBY_VERSION }}
51+
build_platform: ${{ matrix.TARGET.BUILD_PLATFORM }}
52+
platform_suffix: ${{ matrix.TARGET.PLATFORM_SUFFIX }}
53+
image_tag: ${{ matrix.IMAGE_VERSION }}
54+
gh_token: ${{ secrets.gh_token }}
55+
repository_owner: ${{ inputs.repository_owner }}
56+
57+
publish-manifests:
58+
name: Publish Multi-Arch Manifests
59+
needs: build
60+
strategy:
61+
fail-fast: false
62+
matrix:
63+
RUBY_VERSION: ${{ fromJSON(inputs.ruby_versions_json) }}
64+
IMAGE_VERSION: ${{ fromJSON(inputs.image_versions_json) }}
65+
runs-on: ubuntu-24.04
66+
permissions:
67+
contents: read
68+
packages: write
69+
steps:
70+
- name: Publish Multi-Arch Manifest
71+
uses: ./.github/actions/build-and-publish-image
72+
with:
73+
publish_manifest: "true"
74+
ruby_version: ${{ matrix.RUBY_VERSION }}
75+
image_tag: ${{ matrix.IMAGE_VERSION }}
76+
gh_token: ${{ secrets.gh_token }}
77+
repository_owner: ${{ inputs.repository_owner }}

.github/workflows/publish-new-image-version.yaml

Lines changed: 9 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -13,52 +13,16 @@ jobs:
1313
- id: set-matrix
1414
run: echo "matrix=$(cat .github/ruby-versions.json | jq -c '.')" >> $GITHUB_OUTPUT
1515

16-
build:
17-
name: Build Images
16+
publish:
17+
name: Publish Images
1818
needs: setup
19-
strategy:
20-
fail-fast: false
21-
matrix:
22-
RUBY_VERSION: ${{ fromJSON(needs.setup.outputs.matrix) }}
23-
TARGET:
24-
- RUNNER: ubuntu-24.04
25-
BUILD_PLATFORM: linux/amd64
26-
PLATFORM_SUFFIX: amd64
27-
- RUNNER: ubuntu-24.04-arm
28-
BUILD_PLATFORM: linux/arm64
29-
PLATFORM_SUFFIX: arm64
30-
runs-on: ${{ matrix.TARGET.RUNNER }}
19+
uses: ./.github/workflows/publish-images-reusable.yaml
20+
with:
21+
ruby_versions_json: ${{ needs.setup.outputs.matrix }}
22+
image_versions_json: ${{ format('["{0}"]', github.ref_name) }}
23+
repository_owner: ${{ github.repository_owner }}
24+
secrets:
25+
gh_token: ${{ secrets.GITHUB_TOKEN }}
3126
permissions:
3227
contents: read
3328
packages: write
34-
steps:
35-
- name: Build and Publish Image
36-
uses: ./.github/actions/build-and-publish-image
37-
with:
38-
ruby_version: ${{ matrix.RUBY_VERSION }}
39-
build_platform: ${{ matrix.TARGET.BUILD_PLATFORM }}
40-
platform_suffix: ${{ matrix.TARGET.PLATFORM_SUFFIX }}
41-
image_tag: ${{ github.ref_name }}
42-
gh_token: ${{ secrets.GITHUB_TOKEN }}
43-
repository_owner: ${{ github.repository_owner }}
44-
45-
publish-manifests:
46-
name: Publish Multi-Arch Manifests
47-
needs: [setup, build]
48-
strategy:
49-
fail-fast: false
50-
matrix:
51-
RUBY_VERSION: ${{ fromJSON(needs.setup.outputs.matrix) }}
52-
runs-on: ubuntu-24.04
53-
permissions:
54-
contents: read
55-
packages: write
56-
steps:
57-
- name: Publish Multi-Arch Manifest
58-
uses: ./.github/actions/build-and-publish-image
59-
with:
60-
publish_manifest: "true"
61-
ruby_version: ${{ matrix.RUBY_VERSION }}
62-
image_tag: ${{ github.ref_name }}
63-
gh_token: ${{ secrets.GITHUB_TOKEN }}
64-
repository_owner: ${{ github.repository_owner }}

.github/workflows/publish-new-ruby-versions.yaml

Lines changed: 9 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -13,55 +13,15 @@ on:
1313
description: List of image versions to build. Should be an array ["ruby-1.1.0"]
1414

1515
jobs:
16-
build:
17-
name: Build Images
18-
19-
strategy:
20-
fail-fast: false
21-
matrix:
22-
RUBY_VERSION: ${{ fromJSON(github.event.inputs.ruby_versions)}}
23-
IMAGE_VERSION: ${{ fromJSON(github.event.inputs.image_versions)}}
24-
TARGET:
25-
- RUNNER: ubuntu-24.04
26-
BUILD_PLATFORM: linux/amd64
27-
PLATFORM_SUFFIX: amd64
28-
- RUNNER: ubuntu-24.04-arm
29-
BUILD_PLATFORM: linux/arm64
30-
PLATFORM_SUFFIX: arm64
31-
32-
runs-on: ${{ matrix.TARGET.RUNNER }}
33-
permissions:
34-
contents: read
35-
packages: write
36-
steps:
37-
- name: Build and Publish Image
38-
uses: ./.github/actions/build-and-publish-image
39-
with:
40-
ruby_version: ${{ matrix.RUBY_VERSION }}
41-
build_platform: ${{ matrix.TARGET.BUILD_PLATFORM }}
42-
platform_suffix: ${{ matrix.TARGET.PLATFORM_SUFFIX }}
43-
image_tag: ${{ matrix.IMAGE_VERSION }}
44-
gh_token: ${{ secrets.GITHUB_TOKEN }}
45-
repository_owner: ${{ github.repository_owner }}
46-
47-
publish-manifests:
48-
name: Publish Multi-Arch Manifests
49-
needs: build
50-
strategy:
51-
fail-fast: false
52-
matrix:
53-
RUBY_VERSION: ${{ fromJSON(github.event.inputs.ruby_versions)}}
54-
IMAGE_VERSION: ${{ fromJSON(github.event.inputs.image_versions)}}
55-
runs-on: ubuntu-24.04
16+
publish:
17+
name: Publish Images
18+
uses: ./.github/workflows/publish-images-reusable.yaml
19+
with:
20+
ruby_versions_json: ${{ github.event.inputs.ruby_versions }}
21+
image_versions_json: ${{ github.event.inputs.image_versions }}
22+
repository_owner: ${{ github.repository_owner }}
23+
secrets:
24+
gh_token: ${{ secrets.GITHUB_TOKEN }}
5625
permissions:
5726
contents: read
5827
packages: write
59-
steps:
60-
- name: Publish Multi-Arch Manifest
61-
uses: ./.github/actions/build-and-publish-image
62-
with:
63-
publish_manifest: "true"
64-
ruby_version: ${{ matrix.RUBY_VERSION }}
65-
image_tag: ${{ matrix.IMAGE_VERSION }}
66-
gh_token: ${{ secrets.GITHUB_TOKEN }}
67-
repository_owner: ${{ github.repository_owner }}

0 commit comments

Comments
 (0)