Skip to content

Commit b21e20f

Browse files
authored
Extract docker image building in a separate reusable workflow (#19)
1 parent b4fa4b4 commit b21e20f

File tree

7 files changed

+88
-183
lines changed

7 files changed

+88
-183
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Build and Publish Base Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- v*
9+
paths:
10+
- 'base/Dockerfile'
11+
pull_request_target:
12+
paths:
13+
- 'base/Dockerfile'
14+
workflow_dispatch:
15+
16+
jobs:
17+
buildAndPush:
18+
uses: ./.github/workflows/publish-docker.yaml
19+
with:
20+
image: base
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Build and Publish Dev Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- v*
9+
paths:
10+
- 'dev/Dockerfile'
11+
pull_request_target:
12+
paths:
13+
- 'dev/Dockerfile'
14+
workflow_dispatch:
15+
workflow_run:
16+
workflows:
17+
- 'Build and Publish Base Docker Image'
18+
branches-ignore:
19+
- 'feature/**'
20+
- 'fix/**'
21+
- 'bugfix/**'
22+
types:
23+
- completed
24+
25+
jobs:
26+
buildAndPush:
27+
uses: ./.github/workflows/publish-docker.yaml
28+
with:
29+
image: dev

.github/workflows/publish-docker-dev.yml

Lines changed: 0 additions & 83 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Build and Publish Net Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- v*
9+
paths:
10+
- 'net/Dockerfile'
11+
pull_request_target:
12+
paths:
13+
- 'net/Dockerfile'
14+
workflow_dispatch:
15+
workflow_run:
16+
workflows:
17+
- 'Build and Publish Base Docker Image'
18+
branches-ignore:
19+
- 'feature/**'
20+
- 'fix/**'
21+
- 'bugfix/**'
22+
types:
23+
- completed
24+
25+
jobs:
26+
buildAndPush:
27+
uses: ./.github/workflows/publish-docker.yaml
28+
with:
29+
image: net

.github/workflows/publish-docker-net.yml

Lines changed: 0 additions & 83 deletions
This file was deleted.
Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,14 @@
1-
name: Build and Publish Base Docker Image
1+
name: Build and Publish Docker Image
22

33
env:
44
platforms: linux/amd64,linux/arm64
55

66
on:
7-
push:
8-
branches:
9-
- main
10-
tags:
11-
- v*
12-
paths:
13-
- 'base/Dockerfile'
14-
pull_request_target:
15-
paths:
16-
- 'base/Dockerfile'
17-
workflow_dispatch:
18-
7+
workflow_call:
8+
inputs:
9+
image:
10+
required: true
11+
type: string
1912
jobs:
2013
buildAndPush:
2114
runs-on: ubuntu-latest
@@ -27,7 +20,7 @@ jobs:
2720
id: meta
2821
with:
2922
images: |
30-
ghcr.io/${{ github.repository_owner }}/sak-base
23+
ghcr.io/${{ github.repository_owner }}/sak-${{ inputs.image }}
3124
tags: |
3225
type=semver,pattern={{version}}
3326
type=schedule
@@ -41,7 +34,7 @@ jobs:
4134
uses: docker/setup-qemu-action@v3
4235
with:
4336
image: tonistiigi/binfmt:latest
44-
platforms: ${{env.platforms}}
37+
platforms: ${{ env.platforms }}
4538
# workaround for self-hosted runner
4639
# https://github.com/mumoshu/actions-runner-controller-ci/commit/e91c8c0f6ca82aa7618010c6d2f417aa46c4a4bf
4740
- name: Set up Docker Context for Buildx
@@ -65,8 +58,8 @@ jobs:
6558
timeout-minutes: 100
6659
uses: docker/build-push-action@v5
6760
with:
68-
context: base
69-
platforms: ${{env.platforms}}
61+
context: ${{ inputs.image }}
62+
platforms: ${{ env.platforms }}
7063
push: ${{ github.event_name != 'pull_request_target' }}
7164
tags: ${{ steps.meta.outputs.tags }}
7265
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)