From 5b22cfd87a94a865f53b282964961862bbea1861 Mon Sep 17 00:00:00 2001 From: RoguedBear <39442192+RoguedBear@users.noreply.github.com> Date: Mon, 20 Nov 2023 21:10:23 +0530 Subject: [PATCH 1/5] feat: specify image stability type when triggering build --- .github/workflows/build-images.yml | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/.github/workflows/build-images.yml b/.github/workflows/build-images.yml index 7e4ad84..8441e98 100644 --- a/.github/workflows/build-images.yml +++ b/.github/workflows/build-images.yml @@ -4,6 +4,16 @@ on: # schedule: # - cron: '0 0 * * *' # Midnight every day workflow_dispatch: + inputs: + build_type: + description: Build Type + required: true + default: edge + type: choice + options: + - edge + - dev + - stable jobs: build: @@ -28,6 +38,32 @@ jobs: uses: docker/setup-buildx-action@v3 with: install: true + + - name: Create the tag + id: image_tag + run: | + choice="${{ inputs.build_type }}" + out="" + + # if the workflow is running on a branch, let the tag be the branch name + if [[ $GITHUB_REF == "ref/heads/"* ]]; then + echo "TAG=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT + exit 0 + fi + + tag="${GITHUB_REF#refs/tags/}" + case $choice in + edge) + out="TAG=$tag-edge" + ;; + dev) + out="TAG=$tag-dev" + ;; + stable) + out="TAG=$tag-stable,latest" + ;; + esac + echo $out >> $GITHUB_OUTPUT - name: Build and publish image uses: docker/build-push-action@v5 From f2a563dd7ec12fec462e690db9d574d0d72e4099 Mon Sep 17 00:00:00 2001 From: RoguedBear <39442192+RoguedBear@users.noreply.github.com> Date: Mon, 20 Nov 2023 21:21:05 +0530 Subject: [PATCH 2/5] use the generated tag --- .github/workflows/build-images.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-images.yml b/.github/workflows/build-images.yml index 8441e98..26cc0b5 100644 --- a/.github/workflows/build-images.yml +++ b/.github/workflows/build-images.yml @@ -70,5 +70,5 @@ jobs: with: context: . push: true - tags: ${{ vars.DOCKERHUB_TAG }}:latest + tags: ${{ vars.DOCKERHUB_TAG }}:${{ steps.image_tag.outputs.TAG }} platforms: linux/amd64,linux/arm64,linux/arm/v7 \ No newline at end of file From 09ee196d5e5d5640eebec1b62be0cb26d57efb75 Mon Sep 17 00:00:00 2001 From: RoguedBear <39442192+RoguedBear@users.noreply.github.com> Date: Mon, 20 Nov 2023 21:36:29 +0530 Subject: [PATCH 3/5] fix prefix removal --- .github/workflows/build-images.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-images.yml b/.github/workflows/build-images.yml index 26cc0b5..329b7eb 100644 --- a/.github/workflows/build-images.yml +++ b/.github/workflows/build-images.yml @@ -46,12 +46,12 @@ jobs: out="" # if the workflow is running on a branch, let the tag be the branch name - if [[ $GITHUB_REF == "ref/heads/"* ]]; then - echo "TAG=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT + if [[ $GITHUB_REF == "refs/heads/"* ]] ; then + echo "TAG=${GITHUB_REF#'refs/heads/'}" >> $GITHUB_OUTPUT exit 0 fi - tag="${GITHUB_REF#refs/tags/}" + tag="${GITHUB_REF#'refs/tags/'}" case $choice in edge) out="TAG=$tag-edge" From 2a0a8d57fd961869bd5734822df5d6c85dfb91ae Mon Sep 17 00:00:00 2001 From: RoguedBear <39442192+RoguedBear@users.noreply.github.com> Date: Mon, 20 Nov 2023 23:12:07 +0530 Subject: [PATCH 4/5] fix wrong latest tag --- .github/workflows/build-images.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-images.yml b/.github/workflows/build-images.yml index 329b7eb..01e5bf0 100644 --- a/.github/workflows/build-images.yml +++ b/.github/workflows/build-images.yml @@ -60,7 +60,7 @@ jobs: out="TAG=$tag-dev" ;; stable) - out="TAG=$tag-stable,latest" + out="TAG=$tag-stable,${{ vars.DOCKERHUB_TAG }}:latest" ;; esac echo $out >> $GITHUB_OUTPUT From cc5ec8b0ddf989397bbf9798af575bccf328cb63 Mon Sep 17 00:00:00 2001 From: Jayant <39442192+RoguedBear@users.noreply.github.com> Date: Mon, 20 Nov 2023 18:08:11 +0000 Subject: [PATCH 5/5] cache docker build layers * testing if gha cache is used https://docs.docker.com/engine/reference/commandline/buildx_build/#cache-from https://docs.docker.com/engine/reference/commandline/buildx_build/#cache-to * try out inline cache src: https://github.com/moby/buildkit#export-cache * go back to using gha cache --- .github/workflows/build-images.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-images.yml b/.github/workflows/build-images.yml index 01e5bf0..da1f80a 100644 --- a/.github/workflows/build-images.yml +++ b/.github/workflows/build-images.yml @@ -71,4 +71,6 @@ jobs: context: . push: true tags: ${{ vars.DOCKERHUB_TAG }}:${{ steps.image_tag.outputs.TAG }} - platforms: linux/amd64,linux/arm64,linux/arm/v7 \ No newline at end of file + platforms: linux/amd64,linux/arm64,linux/arm/v7 + cache-from: type=gha + cache-to: type=gha,mode=max