fix: tag name contains the user/repo #141
Workflow file for this run
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: | |
# https://docs.docker.com/build/ci/github-actions/multi-platform/ | |
# distributebuild across multiple runners | |
# This step build the same image on different runners / platforms | |
runs-on: ubuntu-latest | |
needs: jeedomInitStep | |
strategy: | |
fail-fast: false | |
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/v6", "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" | |
# exclude Jeedom debug on every buster, useless | |
- debian: "buster" | |
xdebug: false | |
env: | |
REGISTRY_IMAGE: pifou25/jeedom | |
TAG_NAME: ${{ matrix.debian }}-${{ matrix.php }}${{ matrix.target == 'full' && '' || '-light' }}${{ matrix.jeedom == 'beta' && '-beta' || '' }}${{ matrix.xdebug && '-debug' || '' }} | |
steps: | |
- | |
name: Prepare ${{ env.TAG_NAME }}:${{ matrix.platform }} | |
run: | | |
platform=${{ matrix.platform }} | |
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV | |
- | |
name: Checkout | |
uses: actions/[email protected] | |
- | |
name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY_IMAGE }} | |
- | |
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: debug ${{ env.TAG_NAME }}:${{ matrix.platform }} | |
run: | | |
echo "Cache: ${{ runner.os }}-buildx-${{ github.ref_name }}" | |
echo "Labels: ${{ steps.meta.outputs.labels }}" | |
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: build ${{ env.TAG_NAME }}:${{ matrix.platform }} | |
# 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 | |
labels: ${{ steps.meta.outputs.labels }} | |
target: ${{ matrix.target }}_jeedom | |
build-args: | | |
DEBIAN=${{ matrix.debian }} | |
PHP=${{ matrix.php }} | |
JEEDOM_VERSION=${{ matrix.jeedom }} | |
XDEBUG=${{ matrix.xdebug }} | |
platforms: ${{ matrix.platform }} | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache | |
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true | |
tags: ${{ env.REGISTRY_IMAGE }}:${{ env.TAG_NAME }} | |
- | |
name: Export digest | |
run: | | |
mkdir -p /tmp/digests | |
digest="${{ steps.buildJeedom.outputs.digest }}" | |
touch "/tmp/digests/${digest#sha256:}" | |
- | |
name: Upload digest | |
uses: actions/upload-artifact@v4 | |
with: | |
# env.PLATFORM_PAIR from step 1 | |
name: digests-${{ env.PLATFORM_PAIR }} | |
path: /tmp/digests/* | |
if-no-files-found: error | |
retention-days: 1 | |
- 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 | |
merge: | |
# https://docs.docker.com/build/ci/github-actions/multi-platform/ | |
# merge previous builds from different runners &platforms into one common docker image | |
runs-on: ubuntu-latest | |
needs: | |
- jeedomBuild | |
# same matrix as previous step except the platform | |
strategy: | |
fail-fast: false | |
matrix: | |
debian: ["buster", "bullseye", "bookworm"] | |
php: [7.3, 8.1] | |
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" | |
env: | |
REGISTRY_IMAGE: pifou25/jeedom | |
TAG_NAME: ${{ matrix.debian }}-${{ matrix.php }}${{ matrix.target == 'full' && '' || '-light' }}${{ matrix.jeedom == 'beta' && '-beta' || '' }}${{ matrix.xdebug && '-debug' || '' }} | |
GHCR_NAME: ghcr.io/${{ secrets.DOCKER_USER }}/jeedom:${{ matrix.debian }}-${{ matrix.php }}${{ matrix.target == 'full' && '' || '-light' }}${{ matrix.jeedom == 'beta' && '-beta' || '' }}${{ matrix.xdebug && '-debug' || '' }} | |
steps: | |
- | |
name: Download digests | |
uses: actions/download-artifact@v4 | |
with: | |
path: /tmp/digests | |
pattern: digests-* | |
merge-multiple: true | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- | |
name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY_IMAGE }} | |
- | |
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: Create manifest list and push ${{ env.TAG_NAME }} | |
working-directory: /tmp/digests | |
run: | | |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) | |
- | |
name: Inspect image ${{ env.TAG_NAME }} | |
run: | | |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} | |
- | |
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 ${{ env.GHCR_NAME }} | |
continue-on-error: true | |
run: | | |
echo tag=${{ env.REGISTRY_IMAGE }} | |
echo ghcr=${{ env.GHCR_NAME }} | |
docker image tag ${{ env.REGISTRY_IMAGE }} ${{ env.GHCR_NAME }} | |
docker image ls -a | |
docker image push --quiet ${{ env.GHCR_NAME }} | |