Skip to content

Commit ca13f3f

Browse files
committed
ci: use bake in continuos-deliver.yml
Signed-off-by: Niccolò Fei <[email protected]>
1 parent 99052d6 commit ca13f3f

File tree

3 files changed

+25
-19
lines changed

3 files changed

+25
-19
lines changed

.github/workflows/continuous-delivery.yml

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ on:
1414
schedule:
1515
- cron: '0 1 * * *'
1616

17-
# set up environment variables to be used across all the jobs
18-
env:
19-
REGISTRY: "ghcr.io/${{ github.repository_owner }}/postgresql-trunk"
20-
2117
defaults:
2218
run:
2319
# default failure handling for shell scripts in 'run' steps
@@ -31,7 +27,7 @@ jobs:
3127
contents: read
3228
packages: write
3329
outputs:
34-
pg_image: ${{ env.TAG }}
30+
pg_image: ${{ env.PG_IMAGE }}
3531
pg_major: ${{ env.PG_MAJOR }}
3632
cnpg_branch: ${{ env.CNPG_BRANCH }}
3733
test_depth: ${{ env.TEST_DEPTH }}
@@ -59,26 +55,32 @@ jobs:
5955
echo "FEATURE_TYPE=${{ github.event.inputs.feature_type }}" >> $GITHUB_ENV
6056
fi
6157
62-
- name: Set tag
63-
run: |
64-
postgres_img="${{ env.REGISTRY }}:${{ env.PG_MAJOR }}-devel"
65-
echo "TAG=${postgres_img}" >> $GITHUB_ENV
66-
6758
- name: Log in to the GitHub Container registry
6859
uses: docker/login-action@v3
6960
with:
7061
registry: ghcr.io
7162
username: ${{ github.actor }}
7263
password: ${{ secrets.GITHUB_TOKEN }}
7364

74-
- name: Build and load
75-
uses: docker/build-push-action@v6
65+
- name: Set up Docker Buildx
66+
uses: docker/setup-buildx-action@v3
67+
68+
- name: Build and push
69+
uses: docker/bake-action@v6
70+
id: build
71+
env:
72+
environment: production
73+
registry: ghcr.io/${{ github.repository_owner }}
74+
revision: ${{ github.sha }}
75+
pgMajor: ${{ env.PG_MAJOR }}
7676
with:
77-
context: .
7877
push: true
79-
load: false
80-
tags: |
81-
${{ env.TAG }}
78+
79+
# Get a list of the images that were built and pushed. We only care about a single tag for each image.
80+
- name: Generated images
81+
id: images
82+
run: |
83+
echo "PG_IMAGE=$(echo '${{ steps.build.outputs.metadata }}' | jq -c '.["standard"].["image.name"]' | grep -oP '[^,]*\d{12}[^,]*')" >> $GITHUB_ENV
8284
8385
call-reusable-e2e:
8486
if: github.event_name == 'schedule'

defaults.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"PG_IMAGE": "ghcr.io/cloudnative-pg/postgresql-trunk:18-devel",
2+
"PG_IMAGE": "ghcr.io/cloudnative-pg/postgresql-trunk:18-standard-bookworm",
33
"PG_MAJOR": 18,
44
"CNPG_BRANCH": "main",
55
"TEST_DEPTH": 4,

docker-bake.hcl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ variable "revision" {
1919
default = "1"
2020
}
2121

22+
variable "pgMajor" {
23+
default = "18"
24+
}
25+
2226
fullname = ( environment == "testing") ? "${registry}/postgresql-trunk-testing" : "${registry}/postgresql-trunk"
2327
now = timestamp()
2428
title = "PostgreSQL Trunk Containers"
@@ -33,7 +37,7 @@ target "default" {
3337
"standard",
3438
"postgis"
3539
]
36-
pgMajor = ["18"]
40+
pgMajor = ["${pgMajor}"]
3741
base = ["debian:bookworm-slim"]
3842
}
3943

@@ -42,7 +46,7 @@ target "default" {
4246
]
4347

4448
dockerfile = "Dockerfile"
45-
name = "postgresql-${pgMajor}-${tgt}-${distroVersion(base)}"
49+
name = "${tgt}"
4650
tags = [
4751
"${fullname}:${pgMajor}-${tgt}-${distroVersion(base)}",
4852
"${fullname}:${pgMajor}-${formatdate("YYYYMMDDhhmm", now)}-${tgt}-${distroVersion(base)}"

0 commit comments

Comments
 (0)