diff --git a/install/OS_specific/Docker/init_workflow.sh b/.github/scripts/init_workflow.sh similarity index 53% rename from install/OS_specific/Docker/init_workflow.sh rename to .github/scripts/init_workflow.sh index 9b6b4055a2..d4d44a19ec 100644 --- a/install/OS_specific/Docker/init_workflow.sh +++ b/.github/scripts/init_workflow.sh @@ -2,28 +2,32 @@ # this script is used by CI/CD Github Workflow JEEDOM_VERSION=$(cat core/config/version) +# get current jeedom version number, 2 digits e.g. 4.5 JEEDOM_SHORT_VERSION="$(echo "$JEEDOM_VERSION" | awk -F. '{print $1"."$2}')" # Docker hub repository may be overriden REPO=${DOCKER_HUB_REPO:-"jeedom"} if [[ "${GITHUB_REF_NAME}" == "master" ]]; then - JEEDOM_TAGS="${REPO}/jeedom:latest,${REPO}/jeedom:$JEEDOM_SHORT_VERSION"; + # select the only image for 'latest' tag + if [[ "${DEBIAN}" == "bookworm" && "${DATABASE}" == "0" ]]; then + JEEDOM_TAGS="${REPO}/jeedom:latest,${REPO}/jeedom:${JEEDOM_SHORT_VERSION}-${TAG_SUFFIX}"; + else + JEEDOM_TAGS="${REPO}/jeedom:${JEEDOM_SHORT_VERSION}-${TAG_SUFFIX}" + fi GITHUB_BRANCH=${GITHUB_REF_NAME}; elif [[ "${GITHUB_REF_NAME}" == "beta" ]]; then - JEEDOM_TAGS="${REPO}/jeedom:beta"; # ${REPO}/jeedom:$JEEDOM_SHORT_VERSION"; + JEEDOM_TAGS="${REPO}/jeedom:${JEEDOM_SHORT_VERSION}-${TAG_SUFFIX}-beta" GITHUB_BRANCH=${GITHUB_REF_NAME}; else - JEEDOM_TAGS="${REPO}/jeedom:alpha"; + JEEDOM_TAGS="${REPO}/jeedom:${JEEDOM_SHORT_VERSION}-${TAG_SUFFIX}-alpha" GITHUB_BRANCH=alpha; fi -# GITHUB_ENV is the environment variables filename -# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#environment-files -echo "JEEDOM_VERSION=$JEEDOM_VERSION" >> $GITHUB_ENV -echo "JEEDOM_SHORT_VERSION=$JEEDOM_SHORT_VERSION" >> $GITHUB_ENV -echo "JEEDOM_TAGS=$JEEDOM_TAGS" >> $GITHUB_ENV -echo "GITHUB_BRANCH=$GITHUB_BRANCH" >> $GITHUB_ENV -echo "JEEDOM_REPO=$REPO" >> $GITHUB_ENV +# GITHUB_OUTPUT is the output filename +# https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands#setting-an-output-parameter +echo "JEEDOM_TAGS=$JEEDOM_TAGS" >> "$GITHUB_OUTPUT" +echo "GITHUB_BRANCH=$GITHUB_BRANCH" >> "$GITHUB_OUTPUT" +echo "JEEDOM_REPO=$REPO" >> "$GITHUB_OUTPUT" # GITHUB_STEP_SUMMARY is the workflow summary # https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary diff --git a/.github/workflows/docker-image-latest.yml b/.github/workflows/docker-image-latest.yml index bb2be53968..a7c148dfac 100644 --- a/.github/workflows/docker-image-latest.yml +++ b/.github/workflows/docker-image-latest.yml @@ -4,7 +4,7 @@ on: push: # only trigger CI when push on following branches branches: - - 'master' + - master # this is to manually trigger the worklow workflow_dispatch: inputs: @@ -15,19 +15,16 @@ on: jobs: build: runs-on: ubuntu-latest + strategy: + # do every matrix combination, don't stop on errors + fail-fast: false + max-parallel: 4 + matrix: + debian: [bullseye, bookworm] + database: [0, 1] + steps: - - - name: Free disk space - run: | - df -h - sudo rm -rf /usr/share/dotnet - sudo rm -rf /opt/ghc - sudo rm -rf "/usr/local/share/boost" - sudo rm -rf "$AGENT_TOOLSDIRECTORY" - sudo apt-get autoclean -y 2>&1 - docker rmi $(docker image ls -aq) 2>&1 - df -h - + - name: Check Out Repo # Check out the repo, using current branch # https://github.com/marketplace/actions/checkout @@ -36,14 +33,21 @@ jobs: - name: BRANCH name # adding infos in the $GITHUB_ENV file and summary # secret DOCKER_HUB_REPO is optional (default=jeedom) + id: config_tags + env: + DOCKER_HUB_REPO: ${{ secrets.DOCKER_HUB_REPO }} + TAG_SUFFIX: ${{ matrix.database && 'http-' || '' }}${{ matrix.debian }} + DEBIAN: ${{ matrix.debian }} + DATABASE: ${{ matrix.database }} run: | - export DOCKER_HUB_REPO=${{ secrets.DOCKER_HUB_REPO }} - bash install/OS_specific/Docker/init_workflow.sh + bash .github/scripts/init_workflow.sh - name: Set up QEMU # https://github.com/marketplace/actions/docker-setup-qemu # set up more platforms (default = all) uses: docker/setup-qemu-action@v2 + with: + platforms: linux/amd64,linux/arm64 # ,linux/arm/v7 - name: Login to Docker Hub # https://github.com/marketplace/actions/docker-login @@ -66,92 +70,21 @@ jobs: id: cache with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ matrix.debian }} restore-keys: | - ${{ runner.os }}-buildx- + ${{ runner.os }}-buildx-${{ matrix.debian }} - - name: Build and push Jeedom on Debian:Bookworm without internal DB + - name: Build and push Jeedom on Debian:${{ matrix.debian }} ${{ matrix.database && 'with' || 'without' }} internal DB # https://github.com/marketplace/actions/build-and-push-docker-images uses: docker/build-push-action@v3 - continue-on-error: true with: context: ./ file: ./Dockerfile - platforms: linux/amd64,linux/arm64 # ,linux/arm/v7 push: true cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache build-args: | - "VERSION=${{ env.GITHUB_BRANCH }}" - "DEBIAN=bookworm" - "DATABASE=0" - tags: "${{ env.JEEDOM_REPO }}/jeedom:${{ env.JEEDOM_SHORT_VERSION}}-http-bookworm" - - - name: Clean docker image - run: | - docker stop $(docker ps -aq) 2>&1 - docker rm $(docker ps -aq) 2>&1 - docker rmi $(docker image ls -aq) 2>&1 - - - name: Build and push Jeedom on DockerHub - # https://github.com/marketplace/actions/build-and-push-docker-images - uses: docker/build-push-action@v3 - continue-on-error: true - with: - context: ./ - file: ./Dockerfile - platforms: linux/amd64,linux/arm64 # ,linux/arm/v7 - push: true - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache - build-args: "VERSION=${{ env.GITHUB_BRANCH }}" - tags: "${{ env.JEEDOM_TAGS }}" - - - name: Clean docker image - run: | - docker stop $(docker ps -aq) 2>&1 - docker rm $(docker ps -aq) 2>&1 - docker rmi $(docker image ls -aq) 2>&1 - - - name: Build and push Jeedom on Debian:Buster with DB - # https://github.com/marketplace/actions/build-and-push-docker-images - uses: docker/build-push-action@v3 - continue-on-error: true - with: - context: ./ - file: ./Dockerfile - platforms: linux/amd64,linux/arm64 # ,linux/arm/v7 - push: true - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache - build-args: | - "VERSION=${{ env.GITHUB_BRANCH }}" - "DEBIAN=buster" - "DATABASE=1" - tags: "${{ env.JEEDOM_REPO }}/jeedom:${{ env.JEEDOM_SHORT_VERSION}}-buster" - - - name: Clean docker image - run: | - docker stop $(docker ps -aq) 2>&1 - docker rm $(docker ps -aq) 2>&1 - docker rmi $(docker image ls -aq) 2>&1 - - - name: Build and push Jeedom on Debian:Bookworm with DB - # https://github.com/marketplace/actions/build-and-push-docker-images - uses: docker/build-push-action@v3 - continue-on-error: true - with: - context: ./ - file: ./Dockerfile - platforms: linux/amd64,linux/arm64 # ,linux/arm/v7 - push: true - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache - build-args: | - "VERSION=${{ env.GITHUB_BRANCH }}" - "DEBIAN=bookworm" - "DATABASE=1" - tags: "${{ env.JEEDOM_REPO }}/jeedom:${{ env.JEEDOM_SHORT_VERSION}}-bookworm" - - - name: Image digest - run: echo ${{ steps.docker_build.outputs.digest }} + "VERSION=${{ steps.config_tags.outputs.GITHUB_BRANCH }}" + "DEBIAN=${{ matrix.debian }}" + "DATABASE=${{ matrix.database }}" + tags: "${{ steps.config_tags.outputs.JEEDOM_TAGS }}"