Bump cloudnative-pg/postgresql from 15.3-4 to 16.1-3 in /15 #63
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and push container images | |
on: | |
workflow_dispatch: | |
push: | |
branches: [main] | |
paths: | |
- '**/Dockerfile' | |
pull_request: | |
branches: [main] | |
paths: | |
- '**/Dockerfile' | |
env: | |
DOCKER_BUILDKIT: 1 | |
COSIGN_EXPERIMENTAL: 1 | |
jobs: | |
build: | |
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' | |
name: Build and publish image | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
major: [14, 15] | |
permissions: | |
id-token: write # keyless Cosign signatures | |
packages: write # GHCR | |
contents: write # git tags | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- name: Generate docker-compliant image name | |
id: name | |
run: echo "name=zenjoy/postgresql" | tee -a $GITHUB_OUTPUT | |
- name: Parse PostgreSQL version | |
id: version | |
run: | | |
POSTGRESQL_VERSION=$(grep -Eo 'postgresql:[0-9]+\.[0-9]+\-[0-9]+$' ${{ matrix.major }}/Dockerfile | cut -d ':' -f2) | |
MAJOR=$(echo $POSTGRESQL_VERSION | cut -d . -f 1) | |
MINOR=$(echo $POSTGRESQL_VERSION | cut -d . -f 2 | cut -d '-' -f 1) | |
PATCH=$(echo $POSTGRESQL_VERSION | cut -d . -f 2 | cut -d '-' -f 2) | |
echo "major=$MAJOR" | tee -a $GITHUB_OUTPUT | |
echo "minor=$MINOR" | tee -a $GITHUB_OUTPUT | |
echo "patch=$PATCH" | tee -a $GITHUB_OUTPUT | |
echo "version=$MAJOR.$MINOR.$PATCH" | tee -a $GITHUB_OUTPUT | |
- name: Generate build tag from head | |
id: branch | |
run: | | |
export GIT_REF=${GITHUB_HEAD_REF:-$GITHUB_REF_NAME} | |
echo "branch=$(echo ${GIT_REF,,} | sed 's/[^a-zA-Z0-9]/-/g')" | tee -a $GITHUB_OUTPUT | |
- name: Generate Docker metadata with PostgreSQL version | |
uses: docker/metadata-action@v4 | |
id: metadata | |
with: | |
flavor: | | |
latest=${{ matrix.major == '15' }} | |
images: | | |
docker.io/${{ steps.name.outputs.name }} | |
ghcr.io/${{ steps.name.outputs.name }} | |
tags: | | |
type=semver,pattern={{version}},value=v${{ steps.version.outputs.version }} | |
type=semver,pattern={{major}}.{{minor}},value=v${{ steps.version.outputs.version }} | |
type=semver,pattern={{major}},value=v${{ steps.version.outputs.version }} | |
labels: | | |
org.opencontainers.image.title=postgresql | |
- name: Install Cosign | |
uses: sigstore/[email protected] | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USER }} | |
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
- name: Login to GitHub Container Repository | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ github.token }} | |
- name: Publish container image | |
uses: docker/build-push-action@v4 | |
id: publish | |
with: | |
push: true | |
context: '${{ matrix.major }}/.' | |
tags: ${{ steps.metadata.outputs.tags }} | |
labels: ${{ steps.metadata.outputs.labels }} | |
platforms: linux/amd64,linux/arm64 | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Sign container images | |
run: | | |
cosign sign --yes --recursive "docker.io/$IMAGE_NAME@$IMAGE_DIGEST" | |
cosign sign --yes --recursive "ghcr.io/$IMAGE_NAME@$IMAGE_DIGEST" | |
env: | |
IMAGE_NAME: ${{ steps.name.outputs.name }} | |
IMAGE_DIGEST: ${{ steps.publish.outputs.digest }} | |
- name: Push version tags | |
run: | | |
git tag -f "v$MAJOR" | |
git tag -f "v$MAJOR.$MINOR" | |
git tag -f "v$POSTGRESQL_VERSION" | |
git push -f -u origin "v$MAJOR" | |
git push -f -u origin "v$MAJOR.$MINOR" | |
git push -f -u origin "v$POSTGRESQL_VERSION" | |
env: | |
POSTGRESQL_VERSION: ${{ steps.version.outputs.version }} | |
MINOR: ${{ steps.version.outputs.minor }} | |
MAJOR: ${{ steps.version.outputs.major }} |