Skip to content

Container Images from Commitest patch #12

Container Images from Commitest patch

Container Images from Commitest patch #12

name: Build Commitfest Container Images
on:
workflow_dispatch:
inputs:
commitfest_id:
description: "ID of the Commitfest"
required: false
default: ""
patch_id:
description: "ID of the Patch"
required: false
default: ""
# set up environment variables to be used across all the jobs
env:
REGISTRY: "ghcr.io/${{ github.repository_owner }}/postgresql-trunk"
TAG: "commitfest-master"
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:
tag: ${{ env.TAG }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set commitfest branch and tag
if: github.event.inputs.commitfest_id != '' && github.event.inputs.patch_id != ''
run: |
BRANCH="commitfest/${{ github.event.inputs.commitfest_id }}/${{ github.event.inputs.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@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: Commit Fest image build
runs-on: ubuntu-22.04
needs:
- build-pg
steps:
- name: Markdown
run: |
commitFestID=${{ github.event.inputs.commitfest_id }}
commitFestPatchID=${{ github.event.inputs.patch_id }}
commitFestURL="https://commitfest.postgresql.org/${commitFestID}/${commitFestPatchID}"
image="${{ env.REGISTRY }}:${{ needs.build-pg.outputs.tag }}"
imageURL="https://${image}"
echo "# Commit Fest Patch" >> $GITHUB_STEP_SUMMARY
echo "[$commitFestID / $commitFestPatchID]($commitFestURL)" >> $GITHUB_STEP_SUMMARY
echo "# Container Image" >> $GITHUB_STEP_SUMMARY
echo "[$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