-
Notifications
You must be signed in to change notification settings - Fork 8
134 lines (120 loc) · 4.8 KB
/
build-commitfest.yml
File metadata and controls
134 lines (120 loc) · 4.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Container Images from Commitest patch
on:
workflow_dispatch:
inputs:
patch_id:
description: "ID of the Patch"
required: true
major_version:
description: "PostgreSQL major version (leave empty for default)"
required: false
defaults:
run:
# default failure handling for shell scripts in 'run' steps
shell: 'bash -Eeuo pipefail -x {0}'
permissions: read-all
jobs:
build-pg:
name: Build the patch for PostgreSQL
runs-on: ${{ github.repository_owner == 'cloudnative-pg' && 'ubuntu-latest-16-cores' || 'ubuntu-24.04' }}
permissions:
contents: read
packages: write
outputs:
images: ${{ env.IMAGES }}
steps:
- name: Checkout Code
uses: actions/checkout@v6
- name: Set env variables from defaults.json
run: |
for key in $(jq -r 'keys[]' defaults.json); do
echo "$key=$(cat defaults.json | jq -r --arg key "$key" '.[$key]')" >> $GITHUB_ENV
done
# Inputs have priority over defaults.json.
- name: Evaluate E2E workflow inputs
env:
INPUT_MAJOR_VERSION: ${{ github.event.inputs.major_version }}
run: |
if [[ -n "${INPUT_MAJOR_VERSION}" ]]; then
echo "PG_MAJOR=${INPUT_MAJOR_VERSION}" >> $GITHUB_ENV
fi
- name: Set commitfest branch and tag
env:
INPUT_PATCH_ID: ${{ github.event.inputs.patch_id }}
run: |
BRANCH="cf/${INPUT_PATCH_ID}"
TAG="${BRANCH////-}"
echo "TAG=${TAG}" >> $GITHUB_ENV
echo "BRANCH=${BRANCH}" >> $GITHUB_ENV
- name: Log in to the GitHub Container registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Build and push
uses: docker/bake-action@v7
id: build
env:
environment: production
registry: ghcr.io/${{ github.repository_owner }}
revision: ${{ github.sha }}
pgMajor: ${{ env.PG_MAJOR }}
with:
set: |
*.args.PG_REPO=https://github.com/postgresql-cfbot/postgresql.git
*.args.PG_BRANCH=${{ env.BRANCH }}
minimal.tags=${{ env.registry }}/postgresql-trunk:${{ env.PG_MAJOR }}-minimal-${{ env.TAG }}
standard.tags=${{ env.registry }}/postgresql-trunk:${{ env.PG_MAJOR }}-standard-${{ env.TAG }}
postgis.tags=${{ env.registry }}/postgresql-trunk:${{ env.PG_MAJOR }}-postgis-${{ env.TAG }}
push: true
# Get a list of the images that were built and pushed.
- name: Generated images
id: images
env:
BUILD_METADATA: ${{ steps.build.outputs.metadata }}
run: |
IMAGES="$(echo "${BUILD_METADATA}" | jq -r '.[]."image.name"')"
{
echo 'IMAGES<<EOF'
echo "${IMAGES}"
echo EOF
} >> $GITHUB_ENV
generate-summary:
name: Commitfest Image Build summary
runs-on: ubuntu-24.04
needs:
- build-pg
steps:
- name: Output summary
env:
INPUT_PATCH_ID: ${{ github.event.inputs.patch_id }}
BUILD_PG_IMAGES: ${{ needs.build-pg.outputs.images }}
run: |
commitFestPatchID="${INPUT_PATCH_ID}"
commitFestURL="https://commitfest.postgresql.org/patch/${commitFestPatchID}"
images="${BUILD_PG_IMAGES}"
images_list="$(echo $images | tr ' ' '\n' | sed 's/^/https:\/\//')"
minimalImage="$(echo $images | tr ' ' '\n' | grep minimal)"
echo "# Commitfest Image Build summary" >> $GITHUB_STEP_SUMMARY
echo "**Commitfest Patch URL**: [$commitFestPatchID]($commitFestURL)" >> $GITHUB_STEP_SUMMARY
echo "Here's the list of Container Images that have been built:" >> $GITHUB_STEP_SUMMARY
echo "$images_list" >> $GITHUB_STEP_SUMMARY
echo "## CloudNativePG Cluster definition" >> $GITHUB_STEP_SUMMARY
echo "You can create a cluster in CloudNativePG running this image:" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`sh" >> $GITHUB_STEP_SUMMARY
echo "(cat <<EOF" >> $GITHUB_STEP_SUMMARY
echo "apiVersion: postgresql.cnpg.io/v1" >> $GITHUB_STEP_SUMMARY
echo "kind: Cluster" >> $GITHUB_STEP_SUMMARY
echo "metadata:" >> $GITHUB_STEP_SUMMARY
echo " name: commitfest-$commitFestPatchID" >> $GITHUB_STEP_SUMMARY
echo "spec:" >> $GITHUB_STEP_SUMMARY
echo " imageName: $minimalImage" >> $GITHUB_STEP_SUMMARY
echo " instances: 3" >> $GITHUB_STEP_SUMMARY
echo " storage:" >> $GITHUB_STEP_SUMMARY
echo " size: 1Gi" >> $GITHUB_STEP_SUMMARY
echo "EOF" >> $GITHUB_STEP_SUMMARY
echo ") | kubectl apply -f -" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY