Skip to content

Merge pull request #13 from drolx/main #10

Merge pull request #13 from drolx/main

Merge pull request #13 from drolx/main #10

---
name: Build and push docker images
env:
VERSION: 5.10
REGISTRY: ghcr.io
DOCKERHUB_REPOSITORY: ghcr.io/${{ github.repository }}
on:
push:
branches:
- master
defaults:
run:
shell: bash
jobs:
docker-build-push:
name: Build and push docker images
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
os: [alpine]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
submodules: recursive
ref: main
fetch-depth: 0
- 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:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set environment DOCKERHUB_IMAGE_TAGS on master
if: github.ref == 'refs/heads/master' && matrix.os == 'alpine'
run: echo "DOCKERHUB_IMAGE_TAGS=$DOCKERHUB_REPOSITORY:latest" >> $GITHUB_ENV
- name: Set environment DOCKERHUB_IMAGE_TAGS
if: github.ref != 'refs/heads/master'
run: |
_VERSION=${{ env.VERSION }}
_MAJOR_VERSION=${_VERSION%.*}
_DOCKERHUB_IMAGE_TAGS="$DOCKERHUB_REPOSITORY:$_VERSION-${{ matrix.os }}"
_DOCKERHUB_IMAGE_TAGS+=",$DOCKERHUB_REPOSITORY:$_MAJOR_VERSION-${{ matrix.os }}"
_DOCKERHUB_IMAGE_TAGS+=",$DOCKERHUB_REPOSITORY:${{ matrix.os }}"
if [ "${{ matrix.os }}" == "alpine" ]; then
_DOCKERHUB_IMAGE_TAGS+=",$DOCKERHUB_REPOSITORY:$_VERSION"
_DOCKERHUB_IMAGE_TAGS+=",$DOCKERHUB_REPOSITORY:$_MAJOR_VERSION"
fi
echo "DOCKERHUB_IMAGE_TAGS=$_DOCKERHUB_IMAGE_TAGS" >> $GITHUB_ENV
- name: Set environment DOCKERHUB_IMAGE_PLATFORMS
run: |
_DOCKERHUB_IMAGE_PLATFORMS="linux/amd64"
if [ "${{ matrix.os }}" == "debian" ]; then
_DOCKERHUB_IMAGE_PLATFORMS+=",linux/arm64"
elif [ "${{ matrix.os }}" == "ubuntu" ]; then
_DOCKERHUB_IMAGE_PLATFORMS+=",linux/arm/v7,linux/arm64"
fi
echo "DOCKERHUB_IMAGE_PLATFORMS=$_DOCKERHUB_IMAGE_PLATFORMS" >> $GITHUB_ENV
- name: Build and push
if: env.DOCKERHUB_IMAGE_TAGS != ''
uses: docker/build-push-action@v4
with:
context: .
file: docker/Dockerfile.${{ matrix.os }}
tags: ${{ env.DOCKERHUB_IMAGE_TAGS }}
platforms: ${{ env.DOCKERHUB_IMAGE_PLATFORMS }}
push: true