From 2199667f725f0da22bf1dcf4de8cf31a2611ab9e Mon Sep 17 00:00:00 2001 From: Timo Reichl Date: Mon, 6 Jun 2022 21:00:35 +0200 Subject: [PATCH] .github/workflows: Automatically figure out SRCDS-based game images to build and publish Signed-off-by: Timo Reichl --- .github/workflows/docker-build.yml | 14 ++++++++++---- .github/workflows/docker-latest.yml | 24 ++++++++++++++++++------ .github/workflows/docker-tag.yml | 21 ++++++++++++++++----- 3 files changed, 44 insertions(+), 15 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 91ab5c3..49d3321 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -11,7 +11,7 @@ on: env: DOCKER_BUILDKIT: 1 REGISTRY_IMAGE: "ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}-build" - DOCKER_IMAGE_TYPES: "base srcds bms csgo css dods gm hl2mp l4d l4d2" + DOCKER_IMAGE_BASE_ORDER: "base srcds" jobs: build: @@ -20,8 +20,14 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 - - name: Build images + - name: Build base images run: | - for docker_image_type in ${DOCKER_IMAGE_TYPES}; do - docker-compose build ${docker_image_type} + for docker_base_image_type in ${DOCKER_IMAGE_BASE_ORDER}; do + docker-compose build ${docker_base_image_type} + done + + - name: Build SRCDS-based game images + run: | + for docker_srcds_game in $(ls image/games/srcds); do + docker-compose build ${docker_srcds_game} done diff --git a/.github/workflows/docker-latest.yml b/.github/workflows/docker-latest.yml index 9f944e3..ce6e4a9 100644 --- a/.github/workflows/docker-latest.yml +++ b/.github/workflows/docker-latest.yml @@ -8,7 +8,7 @@ on: env: DOCKER_BUILDKIT: 1 REGISTRY_IMAGE: "ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}" - DOCKER_IMAGE_TYPES: "base srcds bms csgo css dods gm hl2mp l4d l4d2" + DOCKER_IMAGE_BASE_ORDER: "base srcds" jobs: build: @@ -23,13 +23,25 @@ jobs: - name: Log in to GHCR run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - - name: Build and push latest images + - name: Build and push latest base images run: | - for docker_image_type in ${DOCKER_IMAGE_TYPES}; do - docker-compose build ${docker_image_type} + for docker_base_image_type in ${DOCKER_IMAGE_BASE_ORDER}; do + docker-compose build ${docker_base_image_type} - src_docker_image=${REGISTRY_IMAGE}:${docker_image_type} - dst_docker_image=${REGISTRY_IMAGE}:${docker_image_type}-latest + src_docker_image=${REGISTRY_IMAGE}:${docker_base_image_type} + dst_docker_image=${REGISTRY_IMAGE}:${docker_base_image_type}-latest + + docker tag ${src_docker_image} ${dst_docker_image} + docker push ${dst_docker_image} + done + + - name: Build and push latest SRCDS-based game images + run: | + for docker_srcds_game in $(ls image/games/srcds); do + docker-compose build ${docker_srcds_game} + + src_docker_image=${REGISTRY_IMAGE}:${docker_srcds_game} + dst_docker_image=${REGISTRY_IMAGE}:${docker_srcds_game}-latest docker tag ${src_docker_image} ${dst_docker_image} docker push ${dst_docker_image} diff --git a/.github/workflows/docker-tag.yml b/.github/workflows/docker-tag.yml index e731aa3..49a51b9 100644 --- a/.github/workflows/docker-tag.yml +++ b/.github/workflows/docker-tag.yml @@ -8,7 +8,7 @@ on: env: DOCKER_BUILDKIT: 1 REGISTRY_IMAGE: "ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}" - DOCKER_IMAGE_TYPES: "base srcds bms csgo css dods gm hl2mp l4d l4d2" + DOCKER_IMAGE_BASE_ORDER: "base srcds" jobs: retag: @@ -23,11 +23,22 @@ jobs: - name: Log in to GHCR run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - - name: Publish tagged images + - name: Publish tagged base images run: | - for docker_image_type in ${DOCKER_IMAGE_TYPES}; do - src_docker_image=${REGISTRY_IMAGE}:${docker_image_type}-latest - dst_docker_image=${REGISTRY_IMAGE}:${docker_image_type}-${{ github.ref_name }} + for docker_base_image_type in ${DOCKER_IMAGE_BASE_ORDER}; do + src_docker_image=${REGISTRY_IMAGE}:${docker_base_image_type}-latest + dst_docker_image=${REGISTRY_IMAGE}:${docker_base_image_type}-${{ github.ref_name }} + + docker pull ${src_docker_image} + docker tag ${src_docker_image} ${dst_docker_image} + docker push ${dst_docker_image} + done + + - name: Publish tagged SRCDS-based game images + run: | + for docker_srcds_game in $(ls image/games/srcds); do + src_docker_image=${REGISTRY_IMAGE}:${docker_srcds_game}-latest + dst_docker_image=${REGISTRY_IMAGE}:${docker_srcds_game}-${{ github.ref_name }} docker pull ${src_docker_image} docker tag ${src_docker_image} ${dst_docker_image}