Merge pull request #34 from SebastianAchilles/cleanup #117
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 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-41 | |
- opensuse-15.6 | |
- rockylinux-8.10 | |
- rockylinux-9.5 | |
- almalinux-8.10 | |
- almalinux-9.5 | |
- 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 | |