Skip to content

Commit 83dd206

Browse files
committed
Deduplicate CI jobs by using GHA matrix context
1 parent a705604 commit 83dd206

File tree

1 file changed

+7
-50
lines changed

1 file changed

+7
-50
lines changed

.github/workflows/docker.yaml

Lines changed: 7 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -9,55 +9,12 @@ env:
99
REGISTRY: ghcr.io
1010

1111
jobs:
12-
builder:
13-
env:
14-
IMAGE_NAME: plato-builder
15-
12+
docker-build:
1613
runs-on: ubuntu-latest
1714

18-
permissions:
19-
packages: write
20-
contents: read
21-
22-
steps:
23-
- name: Checkout repository
24-
uses: actions/checkout@v4
25-
with:
26-
submodules: 'true'
27-
28-
# Extract metadata (tags, labels) for Docker
29-
# https://github.com/docker/metadata-action
30-
- name: Extract Docker metadata
31-
id: meta
32-
uses: docker/metadata-action@v5
33-
with:
34-
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
35-
flavor: latest=true
36-
37-
- name: Log into registry ${{ env.REGISTRY }}
38-
uses: docker/login-action@v3
39-
with:
40-
registry: ${{ env.REGISTRY }}
41-
username: ${{ github.actor }}
42-
password: ${{ secrets.GITHUB_TOKEN }}
43-
44-
# Build and push Docker image with Buildx (don't push on PR)
45-
# https://github.com/docker/build-push-action
46-
- name: Build and push Docker image
47-
id: build-and-push
48-
uses: docker/build-push-action@v6
49-
with:
50-
file: builder.Dockerfile
51-
context: ./plato
52-
push: ${{ github.event_name != 'pull_request' }}
53-
tags: ${{ steps.meta.outputs.tags }}
54-
labels: ${{ steps.meta.outputs.labels }}
55-
56-
emulator:
57-
env:
58-
IMAGE_NAME: plato-emulator
59-
60-
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
purpose: [builder, emulator]
6118

6219
permissions:
6320
packages: write
@@ -75,7 +32,7 @@ jobs:
7532
id: meta
7633
uses: docker/metadata-action@v5
7734
with:
78-
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
35+
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/plato-${{ matrix.purpose }}
7936
flavor: latest=true
8037

8138
- name: Log into registry ${{ env.REGISTRY }}
@@ -91,14 +48,14 @@ jobs:
9148
id: build-and-push
9249
uses: docker/build-push-action@v6
9350
with:
94-
file: emulator.Dockerfile
51+
file: ${{ matrix.purpose }}.Dockerfile
9552
context: ./plato
9653
push: ${{ github.event_name != 'pull_request' }}
9754
tags: ${{ steps.meta.outputs.tags }}
9855
labels: ${{ steps.meta.outputs.labels }}
9956

10057
image-layers:
101-
needs: [builder, emulator]
58+
needs: docker-build
10259

10360
runs-on: ubuntu-latest
10461

0 commit comments

Comments
 (0)