Skip to content

Commit 9388bf3

Browse files
ci: improve reusability of the bake workflow (#317)
Closes #316 Signed-off-by: Niccolò Fei <niccolo.fei@enterprisedb.com> Signed-off-by: Gabriele Bartolini <gabriele.bartolini@enterprisedb.com> Co-authored-by: Gabriele Bartolini <gabriele.bartolini@enterprisedb.com>
1 parent a7dbcbf commit 9388bf3

1 file changed

Lines changed: 33 additions & 3 deletions

File tree

.github/workflows/bake_targets.yml

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,31 @@ on:
44
workflow_call:
55
inputs:
66
environment:
7-
description: "The environment to build for"
7+
description: "Target environment for the image build (e.g. testing, production)."
88
required: true
99
type: string
1010
default: "testing"
1111
postgresql_version:
12-
description: "The PostgreSQL major version to bake"
12+
description: "PostgreSQL major version to pass to bake (e.g. 16, 17)."
1313
required: true
1414
type: string
15+
target:
16+
description: "Bake target name to build (defaults to 'default')."
17+
required: false
18+
default: "default"
19+
type: string
20+
bake_files:
21+
description: "Comma-separated ordered list of bake definition files to load."
22+
required: false
23+
type: string
24+
default: "./docker-bake.hcl"
25+
bake_remote_source:
26+
description: >
27+
Optional Git repository with extra bake definitions (e.g.
28+
cloudnative-pg/postgres-containers). The repository will be mounted under the
29+
`source` directory.
30+
required: false
31+
type: string
1532

1633
permissions: {}
1734

@@ -32,11 +49,22 @@ jobs:
3249
- name: Checkout Code
3350
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
3451

52+
# bake-action/subaction/matrix doesn't support remote bake files.
53+
# As a workaround, we clone the repository to allow passing the path to a local file.
54+
- name: Checkout additional remote source
55+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
56+
if: ${{ inputs.bake_remote_source != '' }}
57+
with:
58+
repository: ${{ inputs.bake_remote_source }}
59+
ref: main
60+
path: source
61+
3562
- name: List targets
3663
id: targets
3764
uses: docker/bake-action/subaction/matrix@3acf805d94d93a86cce4ca44798a76464a75b88c # v6
3865
with:
39-
target: "default"
66+
target: ${{ inputs.target }}
67+
files: ${{ inputs.bake_files }}
4068

4169
- name: Filter by versions
4270
id: extract_targets
@@ -74,6 +102,8 @@ jobs:
74102
revision: ${{ github.sha }}
75103
with:
76104
push: true
105+
source: .
106+
files: ${{ inputs.bake_files }}
77107
targets: ${{ steps.extract_targets.outputs.filtered_targets }}
78108

79109
# Get a list of the images that were built and pushed. We only care about a single tag for each image.

0 commit comments

Comments
 (0)