Skip to content

Commit f9147bb

Browse files
committed
Update docker CI to use a config.json file for the versions
1 parent 36a14ef commit f9147bb

File tree

3 files changed

+52
-5
lines changed

3 files changed

+52
-5
lines changed

.github/workflows/docker-ci.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,29 @@ permissions:
1111
packages: write
1212

1313
jobs:
14-
build:
15-
name: Build
14+
prepare:
15+
name: Prepare Matrix
1616
runs-on: ubuntu-latest
17+
outputs:
18+
ansible-versions: ${{ steps.set-matrix.outputs.ansible-versions }}
19+
steps:
20+
21+
- name: Checkout
22+
uses: actions/checkout@v5
23+
24+
- name: Set Matrix
25+
id: set-matrix
26+
run: |
27+
matrix=$(cat docker/config.json | jq -r '.ansible.versions')
28+
echo "ansible-versions=$matrix" >> $GITHUB_OUTPUT
29+
30+
registry:
31+
name: Build & Push
32+
runs-on: ubuntu-latest
33+
needs: prepare
1734
strategy:
1835
matrix:
19-
ansible-version: [ '12.0.0', '11.10.0', '10.7.0' ]
36+
ansible-version: ${{ fromJson(needs.prepare.outputs.ansible-versions) }}
2037

2138
steps:
2239

.github/workflows/docker-release.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,32 @@ permissions:
99
packages: write
1010

1111
jobs:
12+
prepare:
13+
name: Prepare Matrix
14+
runs-on: ubuntu-latest
15+
outputs:
16+
ansible-versions: ${{ steps.set-matrix.outputs.ansible-versions }}
17+
latest-version: ${{ steps.set-matrix.outputs.latest-version }}
18+
steps:
19+
20+
- name: Checkout
21+
uses: actions/checkout@v5
22+
23+
- name: Set Matrix
24+
id: set-matrix
25+
run: |
26+
matrix=$(cat docker/config.json | jq -r '.ansible.versions')
27+
latest=$(cat docker/config.json | jq -r '.ansible.versions[0]')
28+
echo "ansible-versions=$matrix" >> $GITHUB_OUTPUT
29+
echo "latest-version=$latest" >> $GITHUB_OUTPUT
30+
1231
registry:
13-
name: GitHub Container Registry
32+
name: Build & Push
1433
runs-on: ubuntu-latest
34+
needs: prepare
1535
strategy:
1636
matrix:
17-
ansible-version: [ '12.0.0', '11.10.0', '10.7.0' ]
37+
ansible-version: ${{ fromJson(needs.prepare.outputs.ansible-versions) }}
1838

1939
steps:
2040

@@ -39,6 +59,7 @@ jobs:
3959
tags: |
4060
type=raw,value=${{ matrix.ansible-version }}
4161
type=raw,value=${{ matrix.ansible-version }}-${{ github.ref_name }}
62+
type=raw,value=latest,enable=${{ matrix.ansible-version == needs.prepare.outputs.latest-version }}
4263
4364
- name: Build and Push Docker image
4465
uses: docker/build-push-action@v5

docker/config.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"ansible": {
3+
"versions": [
4+
"12.0.0",
5+
"11.10.0",
6+
"10.7.0"
7+
]
8+
}
9+
}

0 commit comments

Comments
 (0)