Skip to content

Commit 424e519

Browse files
sxdNiccoloFei
andauthored
chore: automatically update available PostgreSQL versions (#269)
Automatically update PostgreSQL versions in the Bake file; this will retrieve the information from the official PostgreSQL website. Closes #153 Signed-off-by: Jonathan Gonzalez V <[email protected]> Signed-off-by: Niccolò Fei <[email protected]> Co-authored-by: Niccolò Fei <[email protected]>
1 parent 635d775 commit 424e519

File tree

2 files changed

+78
-8
lines changed

2 files changed

+78
-8
lines changed

.github/workflows/bake_update.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Update PostgreSQL versions
2+
3+
on:
4+
schedule:
5+
- cron: 0 0 * * 1
6+
workflow_dispatch:
7+
8+
defaults:
9+
run:
10+
shell: 'bash -Eeuo pipefail -x {0}'
11+
12+
permissions: read-all
13+
14+
jobs:
15+
build:
16+
name: Run update script
17+
runs-on: ubuntu-24.04
18+
steps:
19+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
20+
with:
21+
token: ${{ secrets.REPO_GHA_PAT }}
22+
23+
- name: Run update script
24+
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3
25+
with:
26+
timeout_minutes: 15
27+
max_attempts: 3
28+
command: |
29+
VERSIONS="$(
30+
curl -Ss -q https://www.postgresql.org/versions.json \
31+
| jq -r '[.[] | select(.supported == true) | .major + "." + .latestMinor]
32+
| sort
33+
| map(" \"" + . + "\"")
34+
| join(",\n")' \
35+
| sed '1i postgreSQLVersions = [' \
36+
| sed '$a ]'
37+
)"
38+
printf '%s\n' "$VERSIONS" \
39+
| sed -i '/^postgreSQLVersions = \[/,/^]/d;/^\/\/ PostgreSQL versions/r /dev/stdin' docker-bake.hcl
40+
41+
- name: Diff
42+
run: |
43+
git status
44+
git diff
45+
46+
- name: Temporarily disable "include administrators" branch protection
47+
if: ${{ always() && github.ref == 'refs/heads/main' }}
48+
id: disable_include_admins
49+
uses: benjefferies/branch-protection-bot@af281f37de86139d1c7a27b91176b5dc1c2c827c # v1.1.2
50+
with:
51+
access_token: ${{ secrets.REPO_GHA_PAT }}
52+
branch: main
53+
enforce_admins: false
54+
55+
- uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9
56+
with:
57+
author_name: CloudNativePG Automated Updates
58+
author_email: [email protected]
59+
message: 'chore: update PostgreSQL versions'
60+
61+
- name: Enable "include administrators" branch protection
62+
uses: benjefferies/branch-protection-bot@af281f37de86139d1c7a27b91176b5dc1c2c827c # v1.1.2
63+
if: ${{ always() && github.ref == 'refs/heads/main' }}
64+
with:
65+
access_token: ${{ secrets.REPO_GHA_PAT }}
66+
branch: main
67+
enforce_admins: ${{ steps.disable_include_admins.outputs.initial_status }}

docker-bake.hcl

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ now = timestamp()
2020
authors = "The CloudNativePG Contributors"
2121
url = "https://github.com/cloudnative-pg/postgres-containers"
2222

23+
// PostgreSQL versions to build
24+
postgreSQLVersions = [
25+
"13.22",
26+
"14.19",
27+
"15.14",
28+
"16.10",
29+
"17.6",
30+
"18~beta3"
31+
]
32+
2333
extensions = [
2434
"pgaudit",
2535
"pgvector",
@@ -32,14 +42,7 @@ target "default" {
3242
"minimal",
3343
"standard"
3444
]
35-
pgVersion = [
36-
"13.22",
37-
"14.19",
38-
"15.14",
39-
"16.10",
40-
"17.6",
41-
"18~beta3"
42-
]
45+
pgVersion = postgreSQLVersions
4346
base = [
4447
// renovate: datasource=docker versioning=loose
4548
"debian:bookworm-slim@sha256:b1a741487078b369e78119849663d7f1a5341ef2768798f7b7406c4240f86aef",

0 commit comments

Comments
 (0)