Skip to content

Merge pull request #33 from SebastianAchilles/almalinux86 #115

Merge pull request #33 from SebastianAchilles/almalinux86

Merge pull request #33 from SebastianAchilles/almalinux86 #115

name: Build and publish container images
on: [push, pull_request, workflow_dispatch]
jobs:
build_publish:
name: Build/publish
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
strategy:
matrix:
tag:
- centos-7.9-python3
- centos-7.9
- centos-8.5
- centosstream-9
- fedora-35
- fedora-36
- opensuse-15.3
- opensuse-15.4
- rockylinux-8.5
- rockylinux-8.6
- rockylinux-8.7
- rockylinux-8.8
- rockylinux-8.9
- rockylinux-9.0
- rockylinux-9.1
- rockylinux-9.2
- rockylinux-9.3
- almalinux-8.6
- almalinux-9.0
- ubuntu-20.04
- ubuntu-20.04-python2
- ubuntu-22.04
- ubuntu-24.04
fail-fast: false
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ matrix.tag }}
restore-keys: |
${{ runner.os }}-buildx-${{ matrix.tag }}
- name: Login to GitHub Container Registry
if: github.event_name == 'push' && github.ref_name == 'main'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Convert and store repository owner in lowercase
run: |
echo REPOSITORY_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
echo IMAGE_TAG=$(date +"%F")-${{ github.run_id }}.${{ github.run_number }} >> $GITHUB_ENV
- name: Build and push to GitHub Packages
uses: docker/build-push-action@v3
with:
tags: |
ghcr.io/${{ env.REPOSITORY_OWNER }}/${{ matrix.tag }}:latest
ghcr.io/${{ env.REPOSITORY_OWNER }}/${{ matrix.tag }}:${{ env.IMAGE_TAG }}
context: ${{ matrix.tag }}
platforms: |
linux/amd64
linux/arm64
push: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Build and push to amd64
uses: docker/build-push-action@v3
with:
tags: |
ghcr.io/${{ env.REPOSITORY_OWNER }}/${{ matrix.tag }}-amd64:latest
ghcr.io/${{ env.REPOSITORY_OWNER }}/${{ matrix.tag }}-amd64:${{ env.IMAGE_TAG }}
context: ${{ matrix.tag }}
platforms: linux/amd64
push: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
cache-from: type=local,src=/tmp/.buildx-cache
- name: Build and push to arm64
uses: docker/build-push-action@v3
with:
tags: |
ghcr.io/${{ env.REPOSITORY_OWNER }}/${{ matrix.tag }}-arm64:latest
ghcr.io/${{ env.REPOSITORY_OWNER }}/${{ matrix.tag }}-arm64:${{ env.IMAGE_TAG }}
context: ${{ matrix.tag }}
platforms: linux/arm64
push: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
cache-from: type=local,src=/tmp/.buildx-cache