Skip to content

DockerImageUpdateTest #2

DockerImageUpdateTest

DockerImageUpdateTest #2

%YAML 1.1
---
name: 'DockerImageUpdateTest'
# Adapted from https://github.com/marketplace/actions/docker-image-update-checker#minimal
# TODO: check the relevant tags in rel-10_0, rel-10_1, rel-11_0 and trigger rebuilds in these commits
# TODO: saner setup which branch uses which base image
on:
# The trigger on 'workflow_dispatch' allows manual start
# on https://github.com/RotherOSS/otobo/actions/workflows/docker_image_update_checker.yml
workflow_dispatch:
# # The trigger on 'schedule' allows to run daily. Time is in UTC declared in cron syntax.
# # The scheduled jobs run only on the default branch.
# schedule:
# - cron: '37 6 * * *'
jobs:
CheckDockerImageUpdate:
runs-on: 'ubuntu-latest'
strategy:
# set up a loop over OTOBO branches
matrix:
major_minor: [ '11_0_6', ]
include:
- major_minor: '11_0_6'
base_image: 'perl:5.38-bookworm'
steps:
- name: Setting up the environment file
run: |
major_minor="${{ matrix.major_minor }}"
docker_tag="test-${major_minor}"
mixed_case_repository="${{ github.repository }}"
lowercased_repository="${mixed_case_repository,,}"
build_date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
(
echo "otobo_branch=rel-${major_minor}"
echo "otobo_base_image=${{ matrix.base_image }}"
echo "otobo_docker_tag=${docker_tag}"
echo "otobo_image=${lowercased_repository}:${docker_tag}"
echo "otobo_build_date=${build_date}"
) >> $GITHUB_ENV
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: 'check out the relevant OTOBO branch'
uses: actions/checkout@v4
with:
ref: ${{ env.otobo_branch }}
-
# needed for build arg GIT_COMMIT
# can't use github.sha here as we need the commit of the checked out branch
name: 'get the commit SHA of the current checkout'
run: echo "otobo_commit=$(git log -1 '--format=format:%H')" >> $GITHUB_ENV
-
# 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_image }}
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_image -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_image }}
cache-from: type=gha
cache-to: type=gha,mode=max`