Docker build stolon image #21472
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: Docker build stolon image | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 * * * *" | |
push: | |
paths: | |
- '.github/workflows/docker-build-stolon.yml' | |
- 'stolon/**' | |
jobs: | |
build: | |
runs-on: ${{ (github.event_name == 'push') && fromJSON('[ "buildjet-4vcpu-ubuntu-2204-arm" ]') || 'ubuntu-latest' }} | |
strategy: | |
fail-fast: false | |
matrix: | |
postgres-version: | |
- 15 | |
- 14 | |
- 13 | |
- 12 | |
- 11 | |
steps: | |
- name: Get latest commit hash of github.com/docker-library/postgres | |
id: get-latest-commit | |
run: | | |
echo "commit=$(git ls-remote https://github.com/docker-library/postgres.git | head -n1 | awk '{print $1;}')" >> $GITHUB_ENV | |
shell: bash | |
- name: Get latest tag of github.com/sorintlab/stolon | |
id: get-latest-tag | |
run: | | |
echo "tag=$(git ls-remote --refs --tags https://github.com/sorintlab/stolon.git|cut --delimiter='/' --fields=3|sort --version-sort|tail --lines=1)" >> $GITHUB_ENV | |
shell: bash | |
- uses: actions/cache@v2 | |
id: cache | |
with: | |
path: stolon | |
key: ${{ runner.os }}-v4-${{ env.commit }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
if: steps.cache.outputs.cache-hit != 'true' | |
with: | |
platforms: all | |
- name: Check Out Repo | |
uses: actions/checkout@v3 | |
- name: Check Out Repo sorintlab/stolon | |
uses: actions/checkout@v3 | |
if: steps.cache.outputs.cache-hit != 'true' | |
with: | |
repository: "sorintlab/stolon" | |
ref: '${{ env.tag }}' | |
path: 'stolon-git' | |
- name: Login to Quay.io | |
if: steps.cache.outputs.cache-hit != 'true' | |
uses: docker/login-action@v2 | |
with: | |
registry: quay.io | |
username: ${{ secrets.QUAY_USERNAME }} | |
password: ${{ secrets.QUAY_PASSWORD }} | |
- name: Set up Docker Buildx | |
if: steps.cache.outputs.cache-hit != 'true' | |
id: buildx | |
uses: docker/setup-buildx-action@v2 | |
with: | |
version: latest | |
- name: Set up build timestamp | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: echo "timestamp=$(date +%Y%m%d)" >> $GITHUB_ENV | |
- name: Build and push docker image | |
if: steps.cache.outputs.cache-hit != 'true' | |
id: docker_build_new | |
uses: docker/build-push-action@v3 | |
with: | |
context: ./stolon-git | |
file: ./stolon/Dockerfile | |
platforms: linux/amd64,linux/arm64/v8 | |
push: true | |
tags: quay.io/unixfox/stolon:latest-pg${{ matrix.postgres-version }}, quay.io/unixfox/stolon:${{ env.tag }}-pg${{ matrix.postgres-version }}, quay.io/unixfox/stolon:${{ env.tag }}-pg${{ matrix.postgres-version }}-build-${{ env.timestamp }} | |
build-args: PGVERSION=${{ matrix.postgres-version }} |