Skip to content

Commit 7b84e56

Browse files
committed
feat: generate image catalogs
Signed-off-by: Niccolò Fei <niccolo.fei@enterprisedb.com>
1 parent 77a3c48 commit 7b84e56

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

.github/workflows/bake.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,18 @@ jobs:
5656
target: "postgis"
5757
bake_files: "./source/docker-bake.hcl,./docker-bake.hcl"
5858
bake_remote_source: "cloudnative-pg/postgres-containers"
59+
60+
Catalogs:
61+
name: Update Catalogs
62+
needs: Bake
63+
runs-on: ubuntu-24.04
64+
permissions:
65+
contents: write
66+
if: |
67+
github.ref == 'refs/heads/main' &&
68+
( github.event.inputs.environment == 'production' || github.event_name == 'schedule' )
69+
steps:
70+
- name: Repository Dispatch
71+
uses: peter-evans/repository-dispatch@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # v3
72+
with:
73+
event-type: update-catalogs

.github/workflows/catalogs.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Update Catalogs
2+
3+
on:
4+
push:
5+
workflow_dispatch:
6+
repository_dispatch:
7+
types: [update-catalogs]
8+
9+
permissions: read-all
10+
11+
defaults:
12+
run:
13+
shell: "bash -Eeuo pipefail -x {0}"
14+
15+
jobs:
16+
update-catalogs:
17+
runs-on: ubuntu-24.04
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
21+
with:
22+
token: ${{ secrets.REPO_GHA_PAT }}
23+
24+
- name: Gather supported distributions and imageTypes
25+
id: get_env
26+
run: |
27+
DISTROS=$(sed -n '/variable "distributions"/,/}/ { s/^[[:space:]]*"\([^"]*\)".*/\1/p }' docker-bake.hcl | paste -sd, -)
28+
IMAGE_TYPES=$(sed -n '/variable "imageTypes"/,/}/ { s/^[[:space:]]*"\([^"]*\)".*/\1/p }' docker-bake.hcl | paste -sd, -)
29+
echo "distributions=$DISTROS" >> "$GITHUB_OUTPUT"
30+
echo "image_types=$IMAGE_TYPES" >> "$GITHUB_OUTPUT"
31+
32+
- name: Generate catalogs
33+
uses: cloudnative-pg/postgres-containers/.github/actions/generate-catalogs@dev/100
34+
with:
35+
output-dir: image-catalogs/
36+
registry: ghcr.io/cloudnative-pg/postgis-testing
37+
distributions: ${{ steps.get_env.outputs.distributions }}
38+
image-types: ${{ steps.get_env.outputs.image_types }}
39+
regex: '(\d+)(?:\.\d+|beta\d+|rc\d+|alpha\d+)-(\d+(?:\.\d+){1,3})-(\d{12})'
40+
41+
- name: Diff
42+
run: |
43+
git add -A .
44+
git status
45+
git diff --staged
46+
47+
- name: Temporarily disable "include administrators" branch protection
48+
if: ${{ always() && github.ref == 'refs/heads/main' }}
49+
id: disable_include_admins
50+
uses: benjefferies/branch-protection-bot@af281f37de86139d1c7a27b91176b5dc1c2c827c # v1.1.2
51+
with:
52+
access_token: ${{ secrets.REPO_GHA_PAT }}
53+
branch: main
54+
enforce_admins: false
55+
56+
- uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9
57+
if: ${{ github.ref == 'refs/heads/main' }}
58+
with:
59+
add: 'image-catalogs/*.yaml'
60+
author_name: CloudNativePG Automated Updates
61+
author_email: noreply@cnpg.com
62+
message: 'chore: update imageCatalogs'
63+
64+
- name: Enable "include administrators" branch protection
65+
uses: benjefferies/branch-protection-bot@af281f37de86139d1c7a27b91176b5dc1c2c827c # v1.1.2
66+
if: ${{ always() && github.ref == 'refs/heads/main' }}
67+
with:
68+
access_token: ${{ secrets.REPO_GHA_PAT }}
69+
branch: main
70+
enforce_admins: ${{ steps.disable_include_admins.outputs.initial_status }}

0 commit comments

Comments
 (0)