Skip to content

Commit

Permalink
Advanced
Browse files Browse the repository at this point in the history
Signed-off-by: Andreas Heinrich <[email protected]>
  • Loading branch information
andistorm committed Jul 8, 2024
1 parent 81cbeeb commit f93a759
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/deploy-docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ jobs:
depends_on_paths: |
${{ needs.env-setup.outputs.path_to_deploy_single_docker_image_workflow }}
${{ needs.env-setup.outputs.path_to_deploy_docker_images_workflow }}
build_args: |
BASE_IMAGE_TAG=${{ needs.run-env-base.outputs.one_image_tag }}
dev-env-base:
needs:
Expand All @@ -129,6 +131,8 @@ jobs:
depends_on_paths: |
${{ needs.env-setup.outputs.path_to_deploy_single_docker_image_workflow }}
${{ needs.env-setup.outputs.path_to_deploy_docker_images_workflow }}
build_args: |
BASE_IMAGE_TAG=${{ needs.build-env-base.outputs.one_image_tag }}
build-kit:
needs:
- env-setup
Expand All @@ -149,6 +153,8 @@ jobs:
depends_on_paths: |
${{ needs.env-setup.outputs.path_to_deploy_single_docker_image_workflow }}
${{ needs.env-setup.outputs.path_to_deploy_docker_images_workflow }}
build_args: |
BASE_IMAGE_TAG=${{ needs.build-env-base.outputs.one_image_tag }}
# Include deprecated images for backwards compatibility
deprecated-everest-clang-format:
if: ${{ needs.env-setup.outputs.build_deprecated_images == 'true' }}
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/deploy-single-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,20 @@ on:
description: 'Directories that need to be checked for changes before building this image'
required: false
type: string
build_args:
description: 'Build arguments for the Dockerfile'
required: false
type: string
outputs:
rebuild:
description: 'Whether the image is rebuilt or not'
value: ${{ jobs.check.outputs.rebuild }}
image_tags:
description: 'Tags of the deployed image'
value: ${{ jobs.build-and-push.outputs.image_tags }}
one_image_tag:
description: 'One tag of the deployed image'
value: ${{ jobs.build-and-push.outputs.one_image_tag }}
secrets:
SA_GITHUB_PAT:
description: 'Github PAT with access to the repository'
Expand Down Expand Up @@ -146,6 +156,9 @@ jobs:
needs: check
if: ${{ needs.check.outputs.rebuild == 'true' || inputs.force_rebuild }}
runs-on: ubuntu-22.04
outputs:
image_tags: ${{ steps.meta.outputs.tags }}
one_image_tag: ${{ steps.extract-one-tag.outputs.tag }}
steps:
- name: Checkout Dockerfile
uses: actions/checkout@v3
Expand Down Expand Up @@ -178,6 +191,7 @@ jobs:
id: meta
uses: docker/metadata-action@v3
with:
sep-tags: ','
images: |
${{ inputs.docker_registry }}/${{ github.repository_owner }}/${{ inputs.image_name }}
- name: Set up QEMU
Expand All @@ -204,3 +218,31 @@ jobs:
platforms: ${{ steps.parse-platforms.outputs.platforms }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: ${{ inputs.build_args }}
- name: Extract one image tag
id: extract-one-tag
shell: python3 {0}
run: |
import os
tags = "${{ steps.meta.outputs.tags }}".split(",")
if len(tags) == 0:
print("No tags found!❌")
exit(1)
tag = None
for t in tags:
if t.startswith("v"):
tag = t
break
if tag is None:
for t in tags:
if not t.startswith("latest"):
tag = t
break
if tag is None:
tag = tags[0]
if tag is None:
print("No tag found!❌")
exit(1)
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
f.write(f"tag={tag}\n")
print(f"Set tag={tag}")
4 changes: 2 additions & 2 deletions docker/images/build-env-base/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1
# LTODO: pin version
FROM ghcr.io/everest/everest-ci/run-env-base:refactor-docker-images
ARG BASE_IMAGE_TAG=latest
FROM ghcr.io/everest/everest-ci/run-env-base:${BASE_IMAGE_TAG}

RUN apt update \
&& apt install --no-install-recommends -y \
Expand Down
4 changes: 2 additions & 2 deletions docker/images/build-kit/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1
# LTODO: pin version
FROM ghcr.io/everest/everest-ci/build-env-base:refactor-docker-images
ARG BASE_IMAGE_TAG=latest
FROM ghcr.io/everest/everest-ci/build-env-base:${BASE_IMAGE_TAG}


ENV WORKSPACE_PATH=/workspace
Expand Down
4 changes: 2 additions & 2 deletions docker/images/dev-env-base/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1
# LTODO: pin version
FROM ghcr.io/everest/everest-ci/build-env-base:refactor-docker-images
ARG BASE_IMAGE_TAG=latest
FROM ghcr.io/everest/everest-ci/build-env-base:${BASE_IMAGE_TAG}

ARG USERNAME=docker
ARG USER_UID=1000
Expand Down

0 comments on commit f93a759

Please sign in to comment.