fix: condition for xdebug install #3
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' | |
- 'fix/xdebug' | |
# no concurrency, cancel previous running workflow | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
initStep: | |
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.xdebug | |
no-fail: true | |
verbose: true | |
jbuild: | |
# 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: initStep | |
strategy: | |
fail-fast: false | |
matrix: | |
debian: [buster, bullseye, bookworm] | |
php: [7.3, 8.2] | |
# 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: [amd64, arm64, arm/v6, arm/v7] | |
xdebug: [true, false] | |
exclude: | |
# exclude php version for each debian | |
- debian: buster | |
php: 8.2 | |
- debian: bookworm | |
php: 7.3 | |
env: | |
REGISTRY_IMAGE: pifou25/php | |
TAG_NAME: ${{ matrix.debian }}-${{ matrix.php }}${{ matrix.xdebug && '-debug' || '' }}${{ github.ref_name != 'master' && '-dev' || '' }} | |
TAG_LATEST_ENABLED: ${{ (matrix.debian == 'bullseye' && matrix.xdebug == 'false' && github.ref_name == 'master') }} | |
steps: | |
- | |
name: Prepare ${{ env.TAG_NAME }}:${{ matrix.platform }} | |
# replace / by - in platform value | |
run: | | |
platform=linux/${{ matrix.platform }} | |
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV | |
- | |
name: Checkout | |
uses: actions/[email protected] | |
- | |
name: Docker meta | |
id: meta | |
# https://github.com/marketplace/actions/docker-metadata-action | |
uses: docker/metadata-action@v5 | |
with: | |
# list of Docker images to use as base name for tags | |
images: | | |
${{ env.REGISTRY_IMAGE }} | |
ghcr.io/${{ env.REGISTRY_IMAGE }} | |
# generate Docker tags based on the following events/attributes | |
tags: | | |
type=raw,value=${{ env.TAG_NAME }} | |
# set latest tag for default branch | |
type=raw,value=latest,enable=${{ env.TAG_LATEST_ENABLED }} | |
- | |
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: buildx-${{ runner.os }}-${{ matrix.platform }} | |
restore-keys: | | |
buildx-${{ runner.os }}-${{ matrix.platform }} | |
buildx-${{ runner.os }} | |
- | |
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 | |
file: build/Dockerfile.xdebug | |
labels: ${{ steps.meta.outputs.labels }} | |
build-args: | | |
DEBIAN=${{ matrix.debian }} | |
PHP=${{ matrix.php }} | |
XDEBUG=${{ matrix.xdebug }} | |
platforms: linux/${{ 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: Check on failures ${{ env.TAG_NAME }}:${{ matrix.platform }} | |
if: steps.buildJeedom.outcome != 'success' | |
# some debug information in case of error | |
run: | | |
echo "${{ matrix.debian }} PHP${{ matrix.php }} debug ${{ matrix.xdebug }} has Errors! 🚀" >> $GITHUB_STEP_SUMMARY | |
echo "Cache: buildx-${{ runner.os }}-${{ matrix.platform }}-${{ matrix.debian }} hit? ${{ steps.cache.outputs.cache-hit }}" | |
echo "Labels: ${{ steps.meta.outputs.labels }}" >> $GITHUB_STEP_SUMMARY | |
- | |
name: Export digest ${{ env.TAG_NAME }}:${{ matrix.platform }} | |
# export the digest file name into env var named DIGEST-${TAG_NAME} for next step | |
if: steps.buildJeedom.outcome == 'success' | |
run: | | |
mkdir -p /tmp/digests | |
digest="${{ steps.buildJeedom.outputs.digest }}" | |
echo "DIGEST=${digest#sha256:}" >> $GITHUB_ENV | |
touch "/tmp/digests/${digest#sha256:}" | |
- | |
name: Upload digest ${{ env.TAG_NAME }}:${{ matrix.platform }} | |
if: steps.buildJeedom.outcome == 'success' | |
uses: actions/upload-artifact@v4 | |
with: | |
# env.PLATFORM_PAIR from step 1 | |
# get DIGEST-${TAG_NAME} env variable from previous step | |
name: digests-${{ env.TAG_NAME }}-${{ env.PLATFORM_PAIR }} | |
path: /tmp/digests/${{ env.DIGEST }} | |
if-no-files-found: error | |
retention-days: 1 | |
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: | |
- jbuild | |
# same matrix as previous step except the platform | |
strategy: | |
fail-fast: false | |
# limit to avoid error HTTP 409: too many requests | |
max-parallel: 2 | |
matrix: | |
debian: [buster, bullseye, bookworm] | |
php: [7.3, 8.2] | |
xdebug: [true, false] | |
exclude: | |
# exclude php version for each debian | |
- debian: buster | |
php: 8.2 | |
- debian: bookworm | |
php: 7.3 | |
env: | |
REGISTRY_IMAGE: pifou25/php | |
TAG_NAME: ${{ matrix.debian }}-${{ matrix.php }}${{ matrix.xdebug && '-debug' || '' }}${{ github.ref_name != 'master' && '-dev' || '' }} | |
GHCR_NAME: ghcr.io/${{ secrets.DOCKER_USER }}/php | |
TAG_LATEST_ENABLED: ${{ (matrix.debian == 'bullseye' && matrix.xdebug == 'false' && github.ref_name == 'master') }} | |
steps: | |
- | |
name: Download digests | |
uses: actions/download-artifact@v4 | |
with: | |
path: /tmp/digests | |
pattern: digests-${{ env.TAG_NAME }}-* | |
merge-multiple: true | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- | |
name: Docker meta | |
id: meta | |
# https://github.com/marketplace/actions/docker-metadata-action | |
uses: docker/metadata-action@v5 | |
with: | |
# list of Docker images to use as base name for tags | |
images: | | |
${{ env.REGISTRY_IMAGE }} | |
ghcr.io/${{ env.REGISTRY_IMAGE }} | |
# generate Docker tags based on the following events/attributes | |
tags: | | |
type=raw,value=${{ env.TAG_NAME }} | |
# set latest tag for default branch | |
type=raw,value=latest,enable=${{ env.TAG_LATEST_ENABLED }} | |
# label chadburn for the "cron" container | |
labels: | | |
chadburn.enabled=true | |
chadburn.job-exec.jeedom-cron.schedule=@every 1m | |
chadburn.job-exec.jeedom-cron.command=/usr/local/bin/php /var/www/html/core/php/jeeCron.php >> /var/www/html/log/cron.log 2>&1 | |
- | |
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: 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.GHCR_SECRET }} | |
- | |
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 }} | |
# inspect and add a minute sleep to avoid HTTP 429 error (too many requests...) | |
run: | | |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} | |
sleep 30s |