-
Notifications
You must be signed in to change notification settings - Fork 4
110 lines (100 loc) · 3.95 KB
/
build-commitfest.yml
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
name: Container Images from Commitest patch
on:
workflow_dispatch:
inputs:
commitfest_id:
description: "ID of the Commitfest"
required: false
patch_id:
description: "ID of the Patch"
required: false
major_version:
description: "PostgreSQL major version (leave empty for default)"
required: false
# set up environment variables to be used across all the jobs
env:
REGISTRY: "ghcr.io/${{ github.repository_owner }}/postgresql-trunk"
BRANCH: "master"
defaults:
run:
# default failure handling for shell scripts in 'run' steps
shell: 'bash -Eeuo pipefail -x {0}'
jobs:
build-pg:
name: Build the patch for PostgreSQL
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
outputs:
pg_image: "${{ env.REGISTRY }}:${{ env.TAG }}"
steps:
- name: Checkout Code
uses: actions/checkout@v4
- 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
run: |
if [[ -n "${{ github.event.inputs.major_version }}" ]]; then
echo "PG_MAJOR=${{ github.event.inputs.major_version }}" >> $GITHUB_ENV
fi
- name: Set commitfest branch and tag
if: github.event.inputs.commitfest_id != '' && github.event.inputs.patch_id != ''
run: |
BRANCH="cf/${{ github.event.inputs.patch_id }}"
TAG="${{ env.PG_MAJOR }}-${BRANCH////-}"
echo "TAG=${TAG}" >> $GITHUB_ENV
echo "BRANCH=${BRANCH}" >> $GITHUB_ENV
- name: Log in to the GitHub Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
load: false
tags: |
${{ env.REGISTRY }}:${{ env.TAG }}
build-args: |
PG_REPO=https://github.com/postgresql-cfbot/postgresql.git
PG_BRANCH=${{ env.BRANCH }}
generate-summary:
name: Commitfest Image Build summary
runs-on: ubuntu-22.04
needs:
- build-pg
steps:
- name: Output summary
run: |
commitFestID=${{ github.event.inputs.commitfest_id }}
commitFestPatchID=${{ github.event.inputs.patch_id }}
commitFestURL="https://commitfest.postgresql.org/${commitFestID}/${commitFestPatchID}"
image="${{ needs.build-pg.outputs.pg_image }}"
imageURL="https://${image}"
echo "# Commitfest Image Build summary" >> $GITHUB_STEP_SUMMARY
echo "**Commitfest Patch URL**: [$commitFestID / $commitFestPatchID]($commitFestURL)" >> $GITHUB_STEP_SUMMARY
echo "**Container Image**: [$image]($imageURL)" >> $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-$commitFestID-$commitFestPatchID" >> $GITHUB_STEP_SUMMARY
echo "spec:" >> $GITHUB_STEP_SUMMARY
echo " imageName: $image" >> $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