Skip to content

Commit 02b80c3

Browse files
committed
ci: use bake in build-commitfest.yml
Signed-off-by: Niccolò Fei <[email protected]>
1 parent 3ce5bc4 commit 02b80c3

File tree

2 files changed

+37
-26
lines changed

2 files changed

+37
-26
lines changed

.github/workflows/build-commitfest.yml

+33-21
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,11 @@ on:
55
inputs:
66
patch_id:
77
description: "ID of the Patch"
8-
required: false
8+
required: true
99
major_version:
1010
description: "PostgreSQL major version (leave empty for default)"
1111
required: false
1212

13-
# set up environment variables to be used across all the jobs
14-
env:
15-
REGISTRY: "ghcr.io/${{ github.repository_owner }}/postgresql-trunk"
16-
BRANCH: "master"
17-
1813
defaults:
1914
run:
2015
# default failure handling for shell scripts in 'run' steps
@@ -28,7 +23,7 @@ jobs:
2823
contents: read
2924
packages: write
3025
outputs:
31-
pg_image: "${{ env.REGISTRY }}:${{ env.TAG }}"
26+
images: ${{ env.IMAGES }}
3227
steps:
3328
- name: Checkout Code
3429
uses: actions/checkout@v4
@@ -47,10 +42,9 @@ jobs:
4742
fi
4843
4944
- name: Set commitfest branch and tag
50-
if: github.event.inputs.patch_id != ''
5145
run: |
5246
BRANCH="cf/${{ github.event.inputs.patch_id }}"
53-
TAG="${{ env.PG_MAJOR }}-${BRANCH////-}"
47+
TAG="${BRANCH////-}"
5448
echo "TAG=${TAG}" >> $GITHUB_ENV
5549
echo "BRANCH=${BRANCH}" >> $GITHUB_ENV
5650
@@ -61,17 +55,31 @@ jobs:
6155
username: ${{ github.actor }}
6256
password: ${{ secrets.GITHUB_TOKEN }}
6357

58+
- name: Set up Docker Buildx
59+
uses: docker/setup-buildx-action@v3
60+
6461
- name: Build and push
65-
uses: docker/build-push-action@v6
62+
uses: docker/bake-action@v6
63+
id: build
64+
env:
65+
environment: production
66+
registry: ghcr.io/${{ github.repository_owner }}
67+
revision: ${{ github.sha }}
68+
pgMajor: ${{ env.PG_MAJOR }}
6669
with:
67-
context: .
70+
set: |
71+
*.args.PG_REPO=https://github.com/postgresql-cfbot/postgresql.git
72+
*.args.PG_BRANCH=${{ env.BRANCH }}
73+
minimal.tags=${{ env.registry }}/postgresql-trunk:18-minimal-${{ env.TAG }}
74+
standard.tags=${{ env.registry }}/postgresql-trunk:18-standard-${{ env.TAG }}
75+
postgis.tags=${{ env.registry }}/postgresql-trunk:18-postgis-${{ env.TAG }}
6876
push: true
69-
load: false
70-
tags: |
71-
${{ env.REGISTRY }}:${{ env.TAG }}
72-
build-args: |
73-
PG_REPO=https://github.com/postgresql-cfbot/postgresql.git
74-
PG_BRANCH=${{ env.BRANCH }}
77+
78+
# Get a list of the images that were built and pushed.
79+
- name: Generated images
80+
id: images
81+
run: |
82+
echo "IMAGES=$(echo '${{ steps.build.outputs.metadata }}' | jq -c '.[]."image.name"')" >> $GITHUB_ENV
7583
7684
generate-summary:
7785
name: Commitfest Image Build summary
@@ -83,11 +91,15 @@ jobs:
8391
run: |
8492
commitFestPatchID=${{ github.event.inputs.patch_id }}
8593
commitFestURL="https://commitfest.postgresql.org/patch/${commitFestPatchID}"
86-
image="${{ needs.build-pg.outputs.pg_image }}"
87-
imageURL="https://${image}"
94+
image="${{ needs.build-pg.outputs.images }}"
95+
images_list="$(echo $images | jq -r | tr ' ' '\n' | sed 's/^/https:\/\//')"
96+
standardImage="$(echo $images | jq -r | grep standard)"
97+
8898
echo "# Commitfest Image Build summary" >> $GITHUB_STEP_SUMMARY
8999
echo "**Commitfest Patch URL**: [$commitFestPatchID]($commitFestURL)" >> $GITHUB_STEP_SUMMARY
90-
echo "**Container Image**: [$image]($imageURL)" >> $GITHUB_STEP_SUMMARY
100+
echo "Here's the list of Container Images that have been built:" >> $GITHUB_STEP_SUMMARY
101+
echo "$images_list" >> $GITHUB_STEP_SUMMARY
102+
91103
echo "## CloudNativePG Cluster definition" >> $GITHUB_STEP_SUMMARY
92104
echo "You can create a cluster in CloudNativePG running this image:" >> $GITHUB_STEP_SUMMARY
93105
echo "\`\`\`sh" >> $GITHUB_STEP_SUMMARY
@@ -97,7 +109,7 @@ jobs:
97109
echo "metadata:" >> $GITHUB_STEP_SUMMARY
98110
echo " name: commitfest-$commitFestPatchID" >> $GITHUB_STEP_SUMMARY
99111
echo "spec:" >> $GITHUB_STEP_SUMMARY
100-
echo " imageName: $image" >> $GITHUB_STEP_SUMMARY
112+
echo " imageName: $standardImage" >> $GITHUB_STEP_SUMMARY
101113
echo " instances: 3" >> $GITHUB_STEP_SUMMARY
102114
echo " storage:" >> $GITHUB_STEP_SUMMARY
103115
echo " size: 1Gi" >> $GITHUB_STEP_SUMMARY

.github/workflows/build.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ jobs:
6969
set: |
7070
*.args.PG_REPO=${{ github.event.inputs.pg_repo }}
7171
*.args.PG_BRANCH=${{ github.event.inputs.pg_branch }}
72-
minimal.tags=${registry}/postgresql-trunk:18-minimal-${{ github.run_number }}
73-
standard.tags=${registry}/postgresql-trunk:18-standard-${{ github.run_number }}
74-
postgis.tags=${registry}/postgresql-trunk:18-postgis-${{ github.run_number }}
72+
minimal.tags=${{ env.registry }}/postgresql-trunk:18-minimal-${{ github.run_number }}
73+
standard.tags=${{ env.registry }}/postgresql-trunk:18-standard-${{ github.run_number }}
74+
postgis.tags=${{ env.registry }}/postgresql-trunk:18-postgis-${{ github.run_number }}
7575
push: true
7676

7777
# Get a list of the images that were built and pushed.
@@ -92,10 +92,9 @@ jobs:
9292
images="${{ needs.build-pg.outputs.images }}"
9393
images_list="$(echo $images | jq -r | tr ' ' '\n' | sed 's/^/https:\/\//')"
9494
standardImage="$(echo $images | jq -r | grep standard)"
95-
standardImageURL="https://${standardImage}"
9695
9796
echo "# PostgreSQL Image Build summary" >> $GITHUB_STEP_SUMMARY
98-
echo "Here's the list of images that have been built:" >> $GITHUB_STEP_SUMMARY
97+
echo "Here's the list of Container Images that have been built:" >> $GITHUB_STEP_SUMMARY
9998
echo "$images_list" >> $GITHUB_STEP_SUMMARY
10099
101100
echo "## CloudNativePG Cluster definition (example using the standard image)" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)