1414 major_version :
1515 description : " PostgreSQL major version (leave empty for default)"
1616 required : false
17- extra_tag :
18- description : " Optional extra tag (make sure it starts with the PG major)"
19- required : false
20-
21- # set up environment variables to be used across all the jobs
22- env :
23- REGISTRY : " ghcr.io/${{ github.repository_owner }}/postgresql-trunk"
2417
2518defaults :
2619 run :
3528 contents : read
3629 packages : write
3730 outputs :
38- pg_image : ${{ env.TAG }}
31+ images : ${{ env.IMAGES }}
32+ pg_major : ${{ env.PG_MAJOR }}
3933 steps :
4034 - name : Checkout Code
4135 uses : actions/checkout@v4
@@ -53,35 +47,43 @@ jobs:
5347 echo "PG_MAJOR=${{ github.event.inputs.major_version }}" >> $GITHUB_ENV
5448 fi
5549
56- - name : Set tag and optional extra tag
57- run : |
58- TAG="${{ env.REGISTRY }}:${{ env.PG_MAJOR }}-build-${{ github.run_number }}"
59- EXTRA_TAG=""
60- if [[ "${{ github.event.inputs.extra_tag }}" != "" ]]; then
61- EXTRA_TAG="${{ env.REGISTRY }}:${{ github.event.inputs.extra_tag }}"
62- fi
63- echo "TAG=${TAG}" >> $GITHUB_ENV
64- echo "EXTRA_TAG=${EXTRA_TAG}" >> $GITHUB_ENV
65-
6650 - name : Log in to the GitHub Container registry
6751 uses : docker/login-action@v3
6852 with :
6953 registry : ghcr.io
7054 username : ${{ github.actor }}
7155 password : ${{ secrets.GITHUB_TOKEN }}
7256
57+ - name : Set up Docker Buildx
58+ uses : docker/setup-buildx-action@v3
59+
7360 - name : Build and push
74- uses : docker/build-push-action@v6
61+ uses : docker/bake-action@v6
62+ id : build
63+ env :
64+ environment : production
65+ registry : ghcr.io/${{ github.repository_owner }}
66+ revision : ${{ github.sha }}
67+ pgMajor : ${{ env.PG_MAJOR }}
7568 with :
76- context : .
69+ set : |
70+ *.args.PG_REPO=${{ github.event.inputs.pg_repo }}
71+ *.args.PG_BRANCH=${{ github.event.inputs.pg_branch }}
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 }}
7775 push : true
78- load : false
79- tags : |
80- ${{ env.TAG }}
81- ${{ env.EXTRA_TAG }}
82- build-args : |
83- PG_REPO=${{ github.event.inputs.pg_repo }}
84- PG_BRANCH=${{ github.event.inputs.pg_branch }}
76+
77+ # Get a list of the images that were built and pushed.
78+ - name : Generated images
79+ id : images
80+ run : |
81+ IMAGES="$(echo '${{ steps.build.outputs.metadata }}' | jq -r '.[]."image.name"')"
82+ {
83+ echo 'IMAGES<<EOF'
84+ echo "${IMAGES}"
85+ echo EOF
86+ } >> $GITHUB_ENV
8587
8688 generate-summary :
8789 name : PostgreSQL Image Build summary
@@ -92,11 +94,15 @@ jobs:
9294 - name : Output summary
9395 run : |
9496 pg_major="${{ needs.build-pg.outputs.pg_major }}"
95- image="${{ needs.build-pg.outputs.pg_image }}"
96- imageURL="https://${image}"
97+ images="${{ needs.build-pg.outputs.images }}"
98+ images_list="$(echo $images | tr ' ' '\n' | sed 's/^/https:\/\//')"
99+ standardImage="$(echo $images | tr ' ' '\n' | grep standard)"
100+
97101 echo "# PostgreSQL Image Build summary" >> $GITHUB_STEP_SUMMARY
98- echo "**Container Image**: [$image]($imageURL)" >> $GITHUB_STEP_SUMMARY
99- echo "## CloudNativePG Cluster definition" >> $GITHUB_STEP_SUMMARY
102+ echo "Here's the list of Container Images that have been built:" >> $GITHUB_STEP_SUMMARY
103+ echo "$images_list" >> $GITHUB_STEP_SUMMARY
104+
105+ echo "## CloudNativePG Cluster definition (example using the standard image)" >> $GITHUB_STEP_SUMMARY
100106 echo "You can create a cluster in CloudNativePG running this image:" >> $GITHUB_STEP_SUMMARY
101107 echo "\`\`\`sh" >> $GITHUB_STEP_SUMMARY
102108 echo "(cat <<EOF" >> $GITHUB_STEP_SUMMARY
@@ -105,7 +111,7 @@ jobs:
105111 echo "metadata:" >> $GITHUB_STEP_SUMMARY
106112 echo " name: pg-$pg_major-build" >> $GITHUB_STEP_SUMMARY
107113 echo "spec:" >> $GITHUB_STEP_SUMMARY
108- echo " imageName: $image " >> $GITHUB_STEP_SUMMARY
114+ echo " imageName: $standardImage " >> $GITHUB_STEP_SUMMARY
109115 echo " instances: 3" >> $GITHUB_STEP_SUMMARY
110116 echo " storage:" >> $GITHUB_STEP_SUMMARY
111117 echo " size: 1Gi" >> $GITHUB_STEP_SUMMARY
0 commit comments