Skip to content

Build and Push Docker Images #13

Build and Push Docker Images

Build and Push Docker Images #13

name: Build and Push Docker Images
on:
push:
branches:
- main
schedule:
- cron: "0 0 * * 0" # Run every Sunday at midnight UTC
workflow_dispatch: {}
permissions:
contents: read
packages: write
env:
IMAGE_NAME: ghcr.io/${{ github.repository }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-and-push:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
postgres_version: ["13", "14", "15", "16"]
os_version: ["alpine", "alpine3.21", "alpine3.22", "trixie"]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU (amd64, arm64)
uses: docker/setup-qemu-action@v3
with:
platforms: amd64,arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push (${{ matrix.postgres_version }}-${{ matrix.os_version }})
run: |
docker buildx build \
--platform linux/amd64,linux/arm64 \
--build-arg POSTGRES_VERSION=${{ matrix.postgres_version }} \
--file Dockerfile.${{ matrix.os_version }} \
--tag $IMAGE_NAME:${{ matrix.postgres_version }}-${{ matrix.os_version }} \
--push \
.