fix: push to ghcr.io #132
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 Multiplatform Build ci | |
on: | |
push: | |
branches: | |
- 'master' | |
- 'develop' | |
# no concurrency, cancel previous running workflow | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
jeedomInitStep: | |
runs-on: ubuntu-latest | |
steps: | |
- | |
name: Checkout | |
uses: actions/[email protected] | |
- name: Docker Lint | |
# https://github.com/marketplace/actions/hadolint-action | |
uses: hadolint/[email protected] | |
with: | |
dockerfile: build/Dockerfile | |
no-fail: true | |
verbose: true | |
jeedomBuild: | |
runs-on: ubuntu-latest | |
needs: jeedomInitStep | |
strategy: | |
matrix: | |
debian: ["buster", "bullseye", "bookworm"] | |
php: [7.3, 8.1] | |
# linux/amd64,linux/amd64/v2,linux/amd64/v3,linux/arm64,linux/riscv64,linux/ppc64le,linux/s390x,linux/386,linux/mips64le,linux/mips64,linux/arm/v7,linux/arm/v6 | |
platform: ["linux/amd64", "linux/arm64", "linux/arm/v7"] | |
jeedom: ["V4-stable", "beta"] | |
target: ["light", "full"] | |
xdebug: [true, false] | |
exclude: | |
# exclude PHP7.3 on every bookworm OS | |
- debian: "bookworm" | |
php: 7.3 | |
# exclude Jeedom beta on every buster, not supported | |
- debian: "buster" | |
jeedom: "beta" | |
steps: | |
- | |
name: Checkout | |
uses: actions/[email protected] | |
- | |
name: Set up QEMU | |
# https://github.com/marketplace/actions/docker-setup-qemu | |
# set up more platforms (default = all) | |
uses: docker/setup-qemu-action@v3 | |
- | |
name: Set up Docker Buildx | |
id: buildx | |
# https://github.com/marketplace/actions/docker-setup-buildx | |
# set up a multi-platform builder for Docker containers | |
uses: docker/setup-buildx-action@v3 | |
- | |
name: Login to DockerHub | |
# https://github.com/marketplace/actions/docker-login | |
# login to DockerHub with secrets login & token | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USER }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Cache Docker layers | |
# https://github.com/marketplace/actions/cache | |
# this action allows caching dependancies and build output | |
uses: actions/cache@v4 | |
id: cache | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.ref_name }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- | |
name: "${{ matrix.debian }} PHP${{ matrix.php }} target ${{ matrix.target }} branch ${{ matrix.jeedom }} debug ${{ matrix.xdebug }}" | |
run: | | |
echo "Name: ${{ steps.buildx.outputs.name }}" | |
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}" | |
echo "Status: ${{ steps.buildx.outputs.status }}" | |
echo "Flags: ${{ steps.buildx.outputs.flags }}" | |
echo "Platforms: ${{ steps.buildx.outputs.platforms }}" | |
- | |
name: "${{ matrix.debian }} PHP${{ matrix.php }} ${{ matrix.platform }} target=${{ matrix.target }} branch=${{ matrix.jeedom }} ${{ matrix.xdebug && 'debug' || '' }}" | |
# id required for next step that check success | |
id: buildJeedom | |
# https://github.com/marketplace/actions/build-and-push-docker-images | |
uses: docker/build-push-action@v5 | |
# do every matrix combination, don't stop on errors | |
continue-on-error: true | |
with: | |
context: build | |
target: ${{ matrix.target }}_jeedom | |
build-args: | | |
DEBIAN=${{ matrix.debian }} | |
PHP=${{ matrix.php }} | |
JEEDOM_VERSION=${{ matrix.jeedom }} | |
XDEBUG=${{ matrix.xdebug }} | |
platforms: ${{ matrix.platform }} | |
push: true | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache | |
tags: | | |
${{ secrets.DOCKER_USER }}/jeedom:${{ matrix.debian }}-${{ matrix.php }}${{ matrix.target == 'full' && '' || '-light' }}${{ matrix.jeedom == 'beta' && '-beta' || '' }}${{ matrix.xdebug && '-debug' || '' }} | |
- | |
name: Login to GitHub Container Registry | |
# push to multi-registry | |
# https://docs.docker.com/build/ci/github-actions/push-multi-registries/ | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- | |
name: Push to ghcr.io | |
continue-on-error: true | |
run: | | |
TAG=image tag ${{ secrets.DOCKER_USER }}/jeedom:${{ matrix.debian }}-${{ matrix.php }}${{ matrix.target == 'full' && '' || '-light' }}${{ matrix.jeedom == 'beta' && '-beta' || '' }}${{ matrix.xdebug && '-debug' || '' }} | |
echo tag=${TAG} | |
GHCR=ghcr.io/${{ secrets.DOCKER_USER }}/jeedom:${{ matrix.debian }}-${{ matrix.php }}${{ matrix.target == 'full' && '' || '-light' }}${{ matrix.jeedom == 'beta' && '-beta' || '' }}${{ matrix.xdebug && '-debug' || '' }} | |
echo ghcr=${GHCR} | |
docker image tag ${TAG} ${GHCR} | |
docker image ls -a | |
docker image push --quiet ${GHCR} | |
- name: Check on failures | |
if: steps.buildJeedom.outcome != 'success' | |
run: | | |
echo "${{ matrix.debian }} PHP${{ matrix.php }} ${{ matrix.target }} branch ${{ matrix.jeedom }} debug ${{ matrix.xdebug }} has Errors! 🚀" >> $GITHUB_STEP_SUMMARY | |
echo "Name: ${{ steps.buildx.outputs.name }}" >> $GITHUB_STEP_SUMMARY | |
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}" >> $GITHUB_STEP_SUMMARY | |
echo "Status: ${{ steps.buildx.outputs.status }}" >> $GITHUB_STEP_SUMMARY | |
echo "Flags: ${{ steps.buildx.outputs.flags }}" >> $GITHUB_STEP_SUMMARY | |
echo "Platforms: ${{ steps.buildx.outputs.platforms }}" >> $GITHUB_STEP_SUMMARY |