From 24385b514551966fa88068002a2e5c40152f9e40 Mon Sep 17 00:00:00 2001 From: bernhard Date: Tue, 23 Jul 2024 16:17:25 +0200 Subject: [PATCH] Issue #3628: try to build devel images for rel-10_1 --- .github/workflows/cache_local_lib.yml | 2 +- .github/workflows/docker_image_builder.yml | 94 ++++++++++++++++++++++ 2 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/docker_image_builder.yml diff --git a/.github/workflows/cache_local_lib.yml b/.github/workflows/cache_local_lib.yml index 33caee93b1..240fbe5193 100644 --- a/.github/workflows/cache_local_lib.yml +++ b/.github/workflows/cache_local_lib.yml @@ -50,7 +50,7 @@ jobs: path: local key: ${{ runner.os }}-${{steps.get-sha.outputs.result}}-local_lib-20240320a - - name: 'check out OTOBO' + - name: 'check out the relevant OTOBO branch' if: steps.cache_local_lib.outputs.cache-hit != 'true' uses: actions/checkout@v4 diff --git a/.github/workflows/docker_image_builder.yml b/.github/workflows/docker_image_builder.yml new file mode 100644 index 0000000000..9482c8b68d --- /dev/null +++ b/.github/workflows/docker_image_builder.yml @@ -0,0 +1,94 @@ +%YAML 1.1 +--- +name: 'DockerImageBuilder' + +on: + + # build a devel Docker image whenever there is a push into the listed branches + push: + branches: + - rel-10_0 + +jobs: + BuildDockerImage: + + runs-on: 'ubuntu-latest' + + steps: + + - name: Setup + run: | + # e.g rel-10_0 + branch="${{ github.ref_name }}" + # e.g. 10_0 + branch_without_rel="${docker_branch:4}" + build_date=$(date -u +'%Y-%m-%dT%H:%M:%SZ') + ( + echo "otobo_branch=$branch_without_rel" + echo "otobo_build_date=$build_date" + echo "otobo_docker_tag=devel-$branch_without_rel" + echo "otobo_commit=${{ github.sha }}" + ) >> $GITHUB_ENV + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: 'check out the relevant OTOBO branch' + uses: actions/checkout@v4 + + - + # build the image, not pushing yet, no pushing as DockerHub access is not set up yet + # Caching with Github Actions Cache, limited to 10 GB + # context: . indicates that the current checkout is used + name: Build + uses: docker/build-push-action@v6 + with: + load: true + context: . + file: otobo.web.dockerfile + pull: true + build-args: | + BUILD_DATE=${{ env.otobo_build_date }} + DOCKER_TAG=${{ env.otobo_docker_tag }} + GIT_REPO=${{ github.repositoryUrl }} + GIT_BRANCH=${{ env.otobo_branch }} + GIT_COMMIT=${{ env.otobo_commit }} + target: otobo-web + tags: ${{ env.otobo_ref }} + cache-from: type=gha + cache-to: type=gha,mode=max` + + - + # otobo_first_time hasn't run yet, so /opt/otobo is still empty + name: Info + run: | + docker run --rm -w /opt/otobo_install/otobo_next --entrypoint /bin/bash $otobo_ref -c "more git-repo.txt git-branch.txt git-commit.txt RELEASE | cat" + + - + # login to Docker Hub only after the build + name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - + # finally upload to DockerHub + # the built image is already available in the job + name: Push to DockerHub + uses: docker/build-push-action@v6 + with: + push: true + context: . + file: otobo.web.dockerfile + pull: true + build-args: | + BUILD_DATE=${{ env.otobo_build_date }} + DOCKER_TAG=${{ env.otobo_docker_tag }} + GIT_REPO=${{ github.repositoryUrl }} + GIT_BRANCH=${{ env.otobo_branch }} + GIT_COMMIT=${{ env.otobo_commit }} + target: otobo-web + tags: ${{ env.otobo_ref }} + cache-from: type=gha + cache-to: type=gha,mode=max`