From eb52627ee50e461407a2d53d4a1faa3c550afe09 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Wed, 1 May 2024 09:11:33 -0400 Subject: [PATCH 01/27] Allow PR to build firmware --- .github/workflows/build.yaml | 54 +++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 37eaa9a0..4f145364 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,6 +1,7 @@ name: Build firmwares on: + pull_request: push: paths: - Dockerfile @@ -15,23 +16,39 @@ env: REGISTRY: ghcr.io jobs: - build-container: - name: Create build container image - runs-on: ubuntu-latest - permissions: - packages: write + get-build-container-names: + name: Get the possible build containers steps: - uses: actions/checkout@v4.1.4 - name: Create container name id: create-container-name run: | - repository_owner=$(echo $GITHUB_REPOSITORY_OWNER | tr [:upper:] [:lower:]) - image_name="${{ env.REGISTRY }}/$repository_owner/silabs-firmware-builder" + current_user=$(echo $GITHUB_REPOSITORY_OWNER | tr [:upper:] [:lower:]) + current_repo=$(echo ${{ github.event.repository.name }} | tr [:upper:] [:lower:]) + current_image_name="${{ env.REGISTRY }}/$current_user/$current_repo" + tag_name="${{ hashFiles('Dockerfile') }}" - echo "image_name=$image_name" >> $GITHUB_OUTPUT echo "tag_name=$tag_name" >> $GITHUB_OUTPUT - echo "container_name=$image_name:$tag_name" >> $GITHUB_OUTPUT + echo "image_name=$current_image_name" >> $GITHUB_OUTPUT + outputs: + tag_name: ${{ steps.create-container-name.outputs.tag_name }} + image_name: ${{ steps.create-container-name.outputs.current_image_name }} + container_name: ${{ steps.create-container-name.outputs.current_image_name }}:${{ steps.create-container-name.outputs.tag_name }} + + maybe-build-container: + name: Create build container image + needs: [get-build-container-names] + if: >- + (github.event_name != 'pull_request') || + (github.event.pull_request.author_association == 'COLLABORATOR') || + (github.event.pull_request.author_association == 'MEMBER') || + (github.event.pull_request.author_association == 'OWNER') + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - uses: actions/checkout@v4.1.4 - name: Log in to the GitHub container registry uses: docker/login-action@v3.1.0 with: @@ -45,16 +62,21 @@ jobs: with: context: . file: Dockerfile - tags: ${{ steps.create-container-name.outputs.container_name }} - cache-from: ${{ steps.create-container-name.outputs.image_name }}:cache-${{ steps.create-container-name.outputs.tag_name }} - cache-to: ${{ steps.create-container-name.outputs.image_name }}:cache-${{ steps.create-container-name.outputs.tag_name }} + tags: ${{ needs.get-build-container-names.outputs.container_name }} + cache-from: ${{ needs.get-build-container-names.outputs.image_name }}:cache-${{ needs.get-build-container-names.outputs.tag_name }} + cache-to: ${{ needs.get-build-container-names.outputs.image_name }}:cache-${{ needs.get-build-container-names.outputs.tag_name }} push: true + + get-build-container: + name: Get the image name of the build container to use + needs: [maybe-build-container, get-build-container-names] + if: always() # If `maybe-build-container` runs, we should run after it + runs-on: ubuntu-latest outputs: - container_name: ${{ steps.create-container-name.outputs.container_name }} + container_name: ${{ needs.get-build-container-names.outputs.container_name }} list-manifests: name: List firmware manifests - needs: build-container runs-on: ubuntu-latest outputs: matrix: ${{ steps.set-matrix.outputs.matrix }} @@ -66,10 +88,10 @@ jobs: build-firmwares: name: Firmware builder - needs: [list-manifests, build-container] + needs: [list-manifests, get-build-container] runs-on: ubuntu-latest container: - image: ${{ needs.build-container.outputs.container_name }} + image: ${{ needs.get-build-container.outputs.container_name }} options: --user root strategy: matrix: From 82bec236447263dca4c66929f083530b204b8c94 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Wed, 1 May 2024 09:13:08 -0400 Subject: [PATCH 02/27] Add a no-op step --- .github/workflows/build.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 4f145364..507bc861 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -72,6 +72,9 @@ jobs: needs: [maybe-build-container, get-build-container-names] if: always() # If `maybe-build-container` runs, we should run after it runs-on: ubuntu-latest + steps: + - id: noop + run: echo "noop" outputs: container_name: ${{ needs.get-build-container-names.outputs.container_name }} From 51de299e02aa89e191bbfcd330381112771d5488 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Wed, 1 May 2024 09:14:27 -0400 Subject: [PATCH 03/27] Run CI on any push --- .github/workflows/build.yaml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 507bc861..8be05839 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -3,14 +3,6 @@ name: Build firmwares on: pull_request: push: - paths: - - Dockerfile - - .github/workflows/build.yaml - - manifests/**/*.yaml - branches: - - main - tags: - - '*' env: REGISTRY: ghcr.io From 665bd6940c87bb3e70ad34271f6def035fac2b62 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Wed, 1 May 2024 09:14:55 -0400 Subject: [PATCH 04/27] Add missing `runs-on` --- .github/workflows/build.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 8be05839..0cd3148d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -10,6 +10,7 @@ env: jobs: get-build-container-names: name: Get the possible build containers + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4.1.4 - name: Create container name From 2bf77b55f262cbb0e6c52e88dadd9a164fb8c1fc Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Wed, 1 May 2024 09:16:53 -0400 Subject: [PATCH 05/27] Fix typo in `get-build-container-names` output --- .github/workflows/build.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 0cd3148d..221e834e 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -26,8 +26,8 @@ jobs: echo "image_name=$current_image_name" >> $GITHUB_OUTPUT outputs: tag_name: ${{ steps.create-container-name.outputs.tag_name }} - image_name: ${{ steps.create-container-name.outputs.current_image_name }} - container_name: ${{ steps.create-container-name.outputs.current_image_name }}:${{ steps.create-container-name.outputs.tag_name }} + image_name: ${{ steps.create-container-name.outputs.image_name }} + container_name: ${{ steps.create-container-name.outputs.image_name }}:${{ steps.create-container-name.outputs.tag_name }} maybe-build-container: name: Create build container image From 44b250e05756d2a92841f4e28d747b5f03d30299 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Wed, 1 May 2024 09:26:58 -0400 Subject: [PATCH 06/27] Only push the new container if the GitHub event is itself `push` --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 221e834e..2cf071f9 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -58,7 +58,7 @@ jobs: tags: ${{ needs.get-build-container-names.outputs.container_name }} cache-from: ${{ needs.get-build-container-names.outputs.image_name }}:cache-${{ needs.get-build-container-names.outputs.tag_name }} cache-to: ${{ needs.get-build-container-names.outputs.image_name }}:cache-${{ needs.get-build-container-names.outputs.tag_name }} - push: true + push: ${{ github.event_name == 'push' }} get-build-container: name: Get the image name of the build container to use From b71277e71b20573d8481997623ca2118e50f70b9 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Wed, 1 May 2024 13:25:08 -0400 Subject: [PATCH 07/27] Only build the new container if necessary --- .github/workflows/build.yaml | 84 +++++++++++++++++------------------- 1 file changed, 40 insertions(+), 44 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 2cf071f9..471da3ba 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -8,35 +8,8 @@ env: REGISTRY: ghcr.io jobs: - get-build-container-names: - name: Get the possible build containers - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4.1.4 - - name: Create container name - id: create-container-name - run: | - current_user=$(echo $GITHUB_REPOSITORY_OWNER | tr [:upper:] [:lower:]) - current_repo=$(echo ${{ github.event.repository.name }} | tr [:upper:] [:lower:]) - current_image_name="${{ env.REGISTRY }}/$current_user/$current_repo" - - tag_name="${{ hashFiles('Dockerfile') }}" - - echo "tag_name=$tag_name" >> $GITHUB_OUTPUT - echo "image_name=$current_image_name" >> $GITHUB_OUTPUT - outputs: - tag_name: ${{ steps.create-container-name.outputs.tag_name }} - image_name: ${{ steps.create-container-name.outputs.image_name }} - container_name: ${{ steps.create-container-name.outputs.image_name }}:${{ steps.create-container-name.outputs.tag_name }} - - maybe-build-container: + build-container: name: Create build container image - needs: [get-build-container-names] - if: >- - (github.event_name != 'pull_request') || - (github.event.pull_request.author_association == 'COLLABORATOR') || - (github.event.pull_request.author_association == 'MEMBER') || - (github.event.pull_request.author_association == 'OWNER') runs-on: ubuntu-latest permissions: packages: write @@ -48,28 +21,51 @@ jobs: registry: ${{ env.REGISTRY }} username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Create container name + id: create-container-info + run: | + base_image=$(echo ${{ github.event.pull_request.base.repo.full_name }} | tr [:upper:] [:lower:]) + head_image=$(echo ${{ github.event.pull_request.head.repo.full_name }} | tr [:upper:] [:lower:]) + tag_name="${{ hashFiles('Dockerfile') }}" + + # Default to building a new container under the original repo + image_name=$head_image + build=true + + # Check if we can use the base image (Nabu Casa) + if docker manifest inspect ${{ env.REGISTRY }}/$base_image:$tag_name; then + image_name=$base_image + build=false + fi + + # Check if we can use the head image (PR) + if docker manifest inspect ${{ env.REGISTRY }}/$head_image:$tag_name; then + image_name=$head_image + build=false + fi + + echo "build=$build" >> $GITHUB_OUTPUT + echo "tag_name=$tag_name" >> $GITHUB_OUTPUT + echo "image_name=$image_name" >> $GITHUB_OUTPUT + echo "container_name=$image_name:$tag_name" >> $GITHUB_OUTPUT - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3.3.0 + if: steps.create-container-info.outputs.build == 'true' - name: Build and Push uses: docker/build-push-action@v5.3.0 + if: steps.create-container-info.outputs.build == 'true' with: context: . file: Dockerfile - tags: ${{ needs.get-build-container-names.outputs.container_name }} - cache-from: ${{ needs.get-build-container-names.outputs.image_name }}:cache-${{ needs.get-build-container-names.outputs.tag_name }} - cache-to: ${{ needs.get-build-container-names.outputs.image_name }}:cache-${{ needs.get-build-container-names.outputs.tag_name }} - push: ${{ github.event_name == 'push' }} - - get-build-container: - name: Get the image name of the build container to use - needs: [maybe-build-container, get-build-container-names] - if: always() # If `maybe-build-container` runs, we should run after it - runs-on: ubuntu-latest - steps: - - id: noop - run: echo "noop" + tags: ${{ steps.create-container-info.outputs.tag_name }} + cache-from: ${{ steps.create-container-info.outputs.image_name }}:cache-${{ steps.create-container-info.outputs.tag_name }} + cache-to: ${{ steps.create-container-info.outputs.image_name }}:cache-${{ steps.create-container-info.outputs.tag_name }} + push: true outputs: - container_name: ${{ needs.get-build-container-names.outputs.container_name }} + tag_name: ${{ steps.create-container-info.outputs.tag_name }} + image_name: ${{ steps.create-container-info.outputs.image_name }} + container_name: ${{ steps.create-container-info.outputs.container_name }} + list-manifests: name: List firmware manifests @@ -84,10 +80,10 @@ jobs: build-firmwares: name: Firmware builder - needs: [list-manifests, get-build-container] + needs: [list-manifests, build-container] runs-on: ubuntu-latest container: - image: ${{ needs.get-build-container.outputs.container_name }} + image: ${{ env.REGISTRY }}/${{ needs.build-container.outputs.container_name }} options: --user root strategy: matrix: From 32afeb48064f8186bffe8f0e9d24194a8c80e964 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Wed, 1 May 2024 13:26:12 -0400 Subject: [PATCH 08/27] Move `env` variable to step output --- .github/workflows/build.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 471da3ba..391741c8 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -47,7 +47,7 @@ jobs: echo "build=$build" >> $GITHUB_OUTPUT echo "tag_name=$tag_name" >> $GITHUB_OUTPUT echo "image_name=$image_name" >> $GITHUB_OUTPUT - echo "container_name=$image_name:$tag_name" >> $GITHUB_OUTPUT + echo "container_name=${{ env.REGISTRY }}/$image_name:$tag_name" >> $GITHUB_OUTPUT - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3.3.0 if: steps.create-container-info.outputs.build == 'true' @@ -83,7 +83,7 @@ jobs: needs: [list-manifests, build-container] runs-on: ubuntu-latest container: - image: ${{ env.REGISTRY }}/${{ needs.build-container.outputs.container_name }} + image: ${{ needs.build-container.outputs.container_name }} options: --user root strategy: matrix: From c1e64e8437caaa3ce86544129eaa7b2ebbbe36b5 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Wed, 1 May 2024 15:18:55 -0400 Subject: [PATCH 09/27] Only ignore a few paths instead of listing all paths to include --- .github/workflows/build.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 391741c8..3d2ea081 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -2,8 +2,13 @@ name: Build firmwares on: pull_request: + paths-ignore: + - '.gitignore' + - 'README.md' push: - + paths-ignore: + - '.gitignore' + - 'README.md' env: REGISTRY: ghcr.io From 7bf64ee3238ec7b06e189d2c376d0ce32980b5a9 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Wed, 1 May 2024 16:45:12 -0400 Subject: [PATCH 10/27] Use a Python script to query the GitHub API to determine `base` and `head` --- .github/workflows/build.yaml | 78 +++++++++++++++++++++++++----------- 1 file changed, 54 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 3d2ea081..d21f15fe 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,31 +28,61 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Create container name id: create-container-info + shell: python -u {0} run: | - base_image=$(echo ${{ github.event.pull_request.base.repo.full_name }} | tr [:upper:] [:lower:]) - head_image=$(echo ${{ github.event.pull_request.head.repo.full_name }} | tr [:upper:] [:lower:]) - tag_name="${{ hashFiles('Dockerfile') }}" - - # Default to building a new container under the original repo - image_name=$head_image - build=true - - # Check if we can use the base image (Nabu Casa) - if docker manifest inspect ${{ env.REGISTRY }}/$base_image:$tag_name; then - image_name=$base_image - build=false - fi - - # Check if we can use the head image (PR) - if docker manifest inspect ${{ env.REGISTRY }}/$head_image:$tag_name; then - image_name=$head_image - build=false - fi - - echo "build=$build" >> $GITHUB_OUTPUT - echo "tag_name=$tag_name" >> $GITHUB_OUTPUT - echo "image_name=$image_name" >> $GITHUB_OUTPUT - echo "container_name=${{ env.REGISTRY }}/$image_name:$tag_name" >> $GITHUB_OUTPUT + import os + import json + import pathlib + import subprocess + import urllib.request + + GITHUB_OUTPUT = pathlib.Path(os.environ["GITHUB_OUTPUT"]) + TAG_NAME = "${{ hashFiles('Dockerfile') }}" + + + req = urllib.request.Request( + url=f"https://api.github.com/repos/{os.environ['REPOSITORY']}", + headers={ + "Authorization": "token ${{ secrets.GITHUB_TOKEN }}", + "Accept": "application/vnd.github.v3+json", + "X-GitHub-Api-Version": "2022-11-28", + } + ) + + with urllib.request.urlopen(req) as response: + assert response.status == 200 + data = json.loads(response.read().decode()) + + head_image = data["full_name"].lower() + + if data["parent"]: + base_image = data["parent"]["full_name"].lower() + else: + base_image = head_image + + image_name = head_image + build = True + + for image in {base_image, head_image}: + try: + subprocess.run([ + "docker", "manifest", "inspect", + f"{os.environ['REGISTRY']}/{image}:{TAG_NAME}" + ], check=True) + except subprocess.CalledProcessError: + continue + else: + image_name = image + build = False + break + + with GITHUB_OUTPUT.open("a") as f: + f.writelines([ + f"build={build}\n", + f"tag_name={TAG_NAME}\n", + f"image_name={image_name}\n", + f"container_name={os.environ['REGISTRY']}/{image_name}:{TAG_NAME}\n", + ]) - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3.3.0 if: steps.create-container-info.outputs.build == 'true' From bfc2f70f1a3215318bf9c33e907f4738f6ce23dc Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Wed, 1 May 2024 16:48:58 -0400 Subject: [PATCH 11/27] Use correct environment variable name --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index d21f15fe..738737f2 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -41,7 +41,7 @@ jobs: req = urllib.request.Request( - url=f"https://api.github.com/repos/{os.environ['REPOSITORY']}", + url=f"https://api.github.com/repos/{os.environ['GITHUB_REPOSITORY']}", headers={ "Authorization": "token ${{ secrets.GITHUB_TOKEN }}", "Accept": "application/vnd.github.v3+json", From 9b0c5706fb83d29892165eb69fe140187988fa48 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Wed, 1 May 2024 16:58:22 -0400 Subject: [PATCH 12/27] Revert "Use correct environment variable name" This reverts commit bfc2f70f1a3215318bf9c33e907f4738f6ce23dc. --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 738737f2..d21f15fe 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -41,7 +41,7 @@ jobs: req = urllib.request.Request( - url=f"https://api.github.com/repos/{os.environ['GITHUB_REPOSITORY']}", + url=f"https://api.github.com/repos/{os.environ['REPOSITORY']}", headers={ "Authorization": "token ${{ secrets.GITHUB_TOKEN }}", "Accept": "application/vnd.github.v3+json", From eccf22c5bdcc29f83dffa67ca98ee9d1ce0ca2b4 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Wed, 1 May 2024 16:58:28 -0400 Subject: [PATCH 13/27] Revert "Use a Python script to query the GitHub API to determine `base` and `head`" This reverts commit 7bf64ee3238ec7b06e189d2c376d0ce32980b5a9. --- .github/workflows/build.yaml | 78 +++++++++++------------------------- 1 file changed, 24 insertions(+), 54 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index d21f15fe..3d2ea081 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -28,61 +28,31 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Create container name id: create-container-info - shell: python -u {0} run: | - import os - import json - import pathlib - import subprocess - import urllib.request - - GITHUB_OUTPUT = pathlib.Path(os.environ["GITHUB_OUTPUT"]) - TAG_NAME = "${{ hashFiles('Dockerfile') }}" - - - req = urllib.request.Request( - url=f"https://api.github.com/repos/{os.environ['REPOSITORY']}", - headers={ - "Authorization": "token ${{ secrets.GITHUB_TOKEN }}", - "Accept": "application/vnd.github.v3+json", - "X-GitHub-Api-Version": "2022-11-28", - } - ) - - with urllib.request.urlopen(req) as response: - assert response.status == 200 - data = json.loads(response.read().decode()) - - head_image = data["full_name"].lower() - - if data["parent"]: - base_image = data["parent"]["full_name"].lower() - else: - base_image = head_image - - image_name = head_image - build = True - - for image in {base_image, head_image}: - try: - subprocess.run([ - "docker", "manifest", "inspect", - f"{os.environ['REGISTRY']}/{image}:{TAG_NAME}" - ], check=True) - except subprocess.CalledProcessError: - continue - else: - image_name = image - build = False - break - - with GITHUB_OUTPUT.open("a") as f: - f.writelines([ - f"build={build}\n", - f"tag_name={TAG_NAME}\n", - f"image_name={image_name}\n", - f"container_name={os.environ['REGISTRY']}/{image_name}:{TAG_NAME}\n", - ]) + base_image=$(echo ${{ github.event.pull_request.base.repo.full_name }} | tr [:upper:] [:lower:]) + head_image=$(echo ${{ github.event.pull_request.head.repo.full_name }} | tr [:upper:] [:lower:]) + tag_name="${{ hashFiles('Dockerfile') }}" + + # Default to building a new container under the original repo + image_name=$head_image + build=true + + # Check if we can use the base image (Nabu Casa) + if docker manifest inspect ${{ env.REGISTRY }}/$base_image:$tag_name; then + image_name=$base_image + build=false + fi + + # Check if we can use the head image (PR) + if docker manifest inspect ${{ env.REGISTRY }}/$head_image:$tag_name; then + image_name=$head_image + build=false + fi + + echo "build=$build" >> $GITHUB_OUTPUT + echo "tag_name=$tag_name" >> $GITHUB_OUTPUT + echo "image_name=$image_name" >> $GITHUB_OUTPUT + echo "container_name=${{ env.REGISTRY }}/$image_name:$tag_name" >> $GITHUB_OUTPUT - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3.3.0 if: steps.create-container-info.outputs.build == 'true' From bfe4bc99103fe25c5c47548da47ac5c9def897ed Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Wed, 1 May 2024 17:04:03 -0400 Subject: [PATCH 14/27] Handle `push` and `pull_request` separately --- .github/workflows/build.yaml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 3d2ea081..79b4c07f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -26,12 +26,27 @@ jobs: registry: ${{ env.REGISTRY }} username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Create container name - id: create-container-info + - name: Read repository information (push) + id: read-repo-info + if: github.event_name != 'pull_request' + run: | + base_image=$(echo ${{ github.repository }} | tr [:upper:] [:lower:]) + echo "base_image=$base_image" >> $GITHUB_OUTPUT + echo "head_image=$base_image" >> $GITHUB_OUTPUT + - name: Read repository information (pull request) + id: read-repo-info-pr + if: github.event_name == 'pull_request' run: | base_image=$(echo ${{ github.event.pull_request.base.repo.full_name }} | tr [:upper:] [:lower:]) head_image=$(echo ${{ github.event.pull_request.head.repo.full_name }} | tr [:upper:] [:lower:]) - tag_name="${{ hashFiles('Dockerfile') }}" + + echo "base_image=$base_image" >> $GITHUB_OUTPUT + echo "head_image=$head_image" >> $GITHUB_OUTPUT + - name: Create container info + id: create-container-info + run: | + base_image=${{ steps.read-repo-info.outputs.base_image || steps.read-repo-info-pr.outputs.base_image }} + head_image=${{ steps.read-repo-info.outputs.head_image || steps.read-repo-info-pr.outputs.head_image }} # Default to building a new container under the original repo image_name=$head_image From ed4c28e50cbdf0698e20d4fe06ccf6be1439a601 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Wed, 1 May 2024 17:05:23 -0400 Subject: [PATCH 15/27] Forgot `tag_name` --- .github/workflows/build.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 79b4c07f..a6b0d6ef 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -45,8 +45,9 @@ jobs: - name: Create container info id: create-container-info run: | - base_image=${{ steps.read-repo-info.outputs.base_image || steps.read-repo-info-pr.outputs.base_image }} - head_image=${{ steps.read-repo-info.outputs.head_image || steps.read-repo-info-pr.outputs.head_image }} + base_image="${{ steps.read-repo-info.outputs.base_image || steps.read-repo-info-pr.outputs.base_image }}" + head_image="${{ steps.read-repo-info.outputs.head_image || steps.read-repo-info-pr.outputs.head_image }}" + tag_name="${{ hashFiles('Dockerfile') }}" # Default to building a new container under the original repo image_name=$head_image From 01fdab907368a2dcc77a6e6548f46ddb396b6415 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Wed, 1 May 2024 17:19:42 -0400 Subject: [PATCH 16/27] Detect the current PR --- .github/workflows/build.yaml | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index a6b0d6ef..cc47b311 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,10 +1,6 @@ name: Build firmwares on: - pull_request: - paths-ignore: - - '.gitignore' - - 'README.md' push: paths-ignore: - '.gitignore' @@ -26,22 +22,24 @@ jobs: registry: ${{ env.REGISTRY }} username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Read repository information (push) - id: read-repo-info - if: github.event_name != 'pull_request' + - name: Get current PR + id: get-current-pr + uses: 8BitJonny/gh-get-current-pr@3.0.0 + - name: Read repository information (PR) + id: read-repo-info-pr + if: steps.get-current-pr.outputs.pr_found == 'true' run: | - base_image=$(echo ${{ github.repository }} | tr [:upper:] [:lower:]) + base_image=$(echo ${{ fromJSON(steps.get-current-pr.outputs.pr).base.repo.full_name }} | tr [:upper:] [:lower:])) + head_image=$(echo ${{ fromJSON(steps.get-current-pr.outputs.pr).head.repo.full_name }} | tr [:upper:] [:lower:])) echo "base_image=$base_image" >> $GITHUB_OUTPUT echo "head_image=$base_image" >> $GITHUB_OUTPUT - - name: Read repository information (pull request) - id: read-repo-info-pr - if: github.event_name == 'pull_request' + - name: Read repository information (no PR) + id: read-repo-info + if: steps.get-current-pr.outputs.pr_found == 'false' run: | - base_image=$(echo ${{ github.event.pull_request.base.repo.full_name }} | tr [:upper:] [:lower:]) - head_image=$(echo ${{ github.event.pull_request.head.repo.full_name }} | tr [:upper:] [:lower:]) - + base_image=$(echo ${{ github.repository }} | tr [:upper:] [:lower:]) echo "base_image=$base_image" >> $GITHUB_OUTPUT - echo "head_image=$head_image" >> $GITHUB_OUTPUT + echo "head_image=$base_image" >> $GITHUB_OUTPUT - name: Create container info id: create-container-info run: | From 00e09a5bbe17bb85c3a3bc68733b2c6c2858a45c Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Wed, 1 May 2024 17:21:03 -0400 Subject: [PATCH 17/27] Remove extraneous parentheses --- .github/workflows/build.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index cc47b311..5703d322 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -29,8 +29,8 @@ jobs: id: read-repo-info-pr if: steps.get-current-pr.outputs.pr_found == 'true' run: | - base_image=$(echo ${{ fromJSON(steps.get-current-pr.outputs.pr).base.repo.full_name }} | tr [:upper:] [:lower:])) - head_image=$(echo ${{ fromJSON(steps.get-current-pr.outputs.pr).head.repo.full_name }} | tr [:upper:] [:lower:])) + base_image=$(echo ${{ fromJSON(steps.get-current-pr.outputs.pr).base.repo.full_name }} | tr [:upper:] [:lower:]) + head_image=$(echo ${{ fromJSON(steps.get-current-pr.outputs.pr).head.repo.full_name }} | tr [:upper:] [:lower:]) echo "base_image=$base_image" >> $GITHUB_OUTPUT echo "head_image=$base_image" >> $GITHUB_OUTPUT - name: Read repository information (no PR) From c87815ff8ba9081062bc7ce819e0313af3d72cc8 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Wed, 1 May 2024 21:37:02 -0400 Subject: [PATCH 18/27] Ensure CI works for both pull requests and pushes --- .github/workflows/build.yaml | 44 ++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 5703d322..18dc27eb 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,6 +1,10 @@ name: Build firmwares on: + pull_request: + paths-ignore: + - '.gitignore' + - 'README.md' push: paths-ignore: - '.gitignore' @@ -22,29 +26,17 @@ jobs: registry: ${{ env.REGISTRY }} username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Get current PR - id: get-current-pr - uses: 8BitJonny/gh-get-current-pr@3.0.0 - - name: Read repository information (PR) - id: read-repo-info-pr - if: steps.get-current-pr.outputs.pr_found == 'true' - run: | - base_image=$(echo ${{ fromJSON(steps.get-current-pr.outputs.pr).base.repo.full_name }} | tr [:upper:] [:lower:]) - head_image=$(echo ${{ fromJSON(steps.get-current-pr.outputs.pr).head.repo.full_name }} | tr [:upper:] [:lower:]) - echo "base_image=$base_image" >> $GITHUB_OUTPUT - echo "head_image=$base_image" >> $GITHUB_OUTPUT - - name: Read repository information (no PR) + - name: Read repository information id: read-repo-info - if: steps.get-current-pr.outputs.pr_found == 'false' run: | - base_image=$(echo ${{ github.repository }} | tr [:upper:] [:lower:]) - echo "base_image=$base_image" >> $GITHUB_OUTPUT - echo "head_image=$base_image" >> $GITHUB_OUTPUT - - name: Create container info - id: create-container-info - run: | - base_image="${{ steps.read-repo-info.outputs.base_image || steps.read-repo-info-pr.outputs.base_image }}" - head_image="${{ steps.read-repo-info.outputs.head_image || steps.read-repo-info-pr.outputs.head_image }}" + if $GITHUB_EVENT_NAME == 'pull_request'; then + base_image=$(echo ${{ github.event.pull_request.base.repo.full_name }} | awk '{print tolower($0)}') + head_image=$(echo ${{ github.event.pull_request.head.repo.full_name }} | awk '{print tolower($0)}') + else + base_image=$(echo ${{ github.repository }} | awk '{print tolower($0)}') + head_image=$(echo ${{ github.repository }} | awk '{print tolower($0)}') + fi + tag_name="${{ hashFiles('Dockerfile') }}" # Default to building a new container under the original repo @@ -57,10 +49,12 @@ jobs: build=false fi - # Check if we can use the head image (PR) - if docker manifest inspect ${{ env.REGISTRY }}/$head_image:$tag_name; then - image_name=$head_image - build=false + # Check if we can use the head image (if this is a PR) + if [[ $base_image != $head_image ]]; then + if docker manifest inspect ${{ env.REGISTRY }}/$head_image:$tag_name; then + image_name=$head_image + build=false + fi fi echo "build=$build" >> $GITHUB_OUTPUT From 13d64a4d77e19fdec73c5882aa1ba767de6581c7 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Wed, 1 May 2024 21:51:09 -0400 Subject: [PATCH 19/27] Fix shell script logic --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 18dc27eb..9ecfa728 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -29,7 +29,7 @@ jobs: - name: Read repository information id: read-repo-info run: | - if $GITHUB_EVENT_NAME == 'pull_request'; then + if [[ $GITHUB_EVENT_NAME == "pull_request" ]]; then base_image=$(echo ${{ github.event.pull_request.base.repo.full_name }} | awk '{print tolower($0)}') head_image=$(echo ${{ github.event.pull_request.head.repo.full_name }} | awk '{print tolower($0)}') else From dc4dfcdf98b5596c67f7efa1ed4d35d79211cfbc Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Wed, 1 May 2024 21:54:56 -0400 Subject: [PATCH 20/27] Use correct step name in `steps.` --- .github/workflows/build.yaml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9ecfa728..08ed4261 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -41,43 +41,43 @@ jobs: # Default to building a new container under the original repo image_name=$head_image - build=true + build_image=true # Check if we can use the base image (Nabu Casa) if docker manifest inspect ${{ env.REGISTRY }}/$base_image:$tag_name; then image_name=$base_image - build=false + build_image=false fi # Check if we can use the head image (if this is a PR) if [[ $base_image != $head_image ]]; then if docker manifest inspect ${{ env.REGISTRY }}/$head_image:$tag_name; then image_name=$head_image - build=false + build_image=false fi fi - echo "build=$build" >> $GITHUB_OUTPUT + echo "build_image=$build_image" >> $GITHUB_OUTPUT echo "tag_name=$tag_name" >> $GITHUB_OUTPUT echo "image_name=$image_name" >> $GITHUB_OUTPUT echo "container_name=${{ env.REGISTRY }}/$image_name:$tag_name" >> $GITHUB_OUTPUT - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3.3.0 - if: steps.create-container-info.outputs.build == 'true' + if: steps.read-repo-info.outputs.build_image == 'true' - name: Build and Push - uses: docker/build-push-action@v5.3.0 - if: steps.create-container-info.outputs.build == 'true' + uses: docker/build_image-push-action@v5.3.0 + if: steps.read-repo-info.outputs.build_image == 'true' with: context: . file: Dockerfile - tags: ${{ steps.create-container-info.outputs.tag_name }} - cache-from: ${{ steps.create-container-info.outputs.image_name }}:cache-${{ steps.create-container-info.outputs.tag_name }} - cache-to: ${{ steps.create-container-info.outputs.image_name }}:cache-${{ steps.create-container-info.outputs.tag_name }} + tags: ${{ steps.read-repo-info.outputs.tag_name }} + cache-from: ${{ steps.read-repo-info.outputs.image_name }}:cache-${{ steps.read-repo-info.outputs.tag_name }} + cache-to: ${{ steps.read-repo-info.outputs.image_name }}:cache-${{ steps.read-repo-info.outputs.tag_name }} push: true outputs: - tag_name: ${{ steps.create-container-info.outputs.tag_name }} - image_name: ${{ steps.create-container-info.outputs.image_name }} - container_name: ${{ steps.create-container-info.outputs.container_name }} + tag_name: ${{ steps.read-repo-info.outputs.tag_name }} + image_name: ${{ steps.read-repo-info.outputs.image_name }} + container_name: ${{ steps.read-repo-info.outputs.container_name }} list-manifests: From 7abfe1d607a360a9c920c6ab5ac6396369107b8b Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Wed, 1 May 2024 21:55:53 -0400 Subject: [PATCH 21/27] Oops, too many replaces --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 08ed4261..04a4764f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -65,7 +65,7 @@ jobs: uses: docker/setup-buildx-action@v3.3.0 if: steps.read-repo-info.outputs.build_image == 'true' - name: Build and Push - uses: docker/build_image-push-action@v5.3.0 + uses: docker/build-push-action@v5.3.0 if: steps.read-repo-info.outputs.build_image == 'true' with: context: . From b14e6ce629a84a71bb3e79659b4b117e475da192 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Thu, 2 May 2024 20:04:33 -0400 Subject: [PATCH 22/27] Truncate the tag name to 16 characters --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 04a4764f..e881559a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -37,7 +37,7 @@ jobs: head_image=$(echo ${{ github.repository }} | awk '{print tolower($0)}') fi - tag_name="${{ hashFiles('Dockerfile') }}" + tag_name=$(echo "${{ hashFiles('Dockerfile') }}" | cut -c-16) # Default to building a new container under the original repo image_name=$head_image From d94a823e7dec07daa20d7be1afad97b466c08146 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Fri, 3 May 2024 09:36:55 -0400 Subject: [PATCH 23/27] Include the registry name in Docker steps --- .github/workflows/build.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index e881559a..64635d78 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -19,7 +19,6 @@ jobs: permissions: packages: write steps: - - uses: actions/checkout@v4.1.4 - name: Log in to the GitHub container registry uses: docker/login-action@v3.1.0 with: @@ -70,9 +69,9 @@ jobs: with: context: . file: Dockerfile - tags: ${{ steps.read-repo-info.outputs.tag_name }} - cache-from: ${{ steps.read-repo-info.outputs.image_name }}:cache-${{ steps.read-repo-info.outputs.tag_name }} - cache-to: ${{ steps.read-repo-info.outputs.image_name }}:cache-${{ steps.read-repo-info.outputs.tag_name }} + tags: ${{ env.REGISTRY }}/${{ steps.read-repo-info.outputs.image_name }}:${{ steps.read-repo-info.outputs.tag_name }} + cache-from: ${{ env.REGISTRY }}/${{ steps.read-repo-info.outputs.image_name }}:cache-${{ steps.read-repo-info.outputs.tag_name }} + cache-to: ${{ env.REGISTRY }}/${{ steps.read-repo-info.outputs.image_name }}:cache-${{ steps.read-repo-info.outputs.tag_name }} push: true outputs: tag_name: ${{ steps.read-repo-info.outputs.tag_name }} From 0e4000ac138588301e7e263b684ff9e13f6661ff Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Fri, 3 May 2024 09:39:07 -0400 Subject: [PATCH 24/27] Revert removal of `actions/checkout` --- .github/workflows/build.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 64635d78..2fe4e628 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -19,6 +19,7 @@ jobs: permissions: packages: write steps: + - uses: actions/checkout@v4.1.4 - name: Log in to the GitHub container registry uses: docker/login-action@v3.1.0 with: From 469fae7ffb7b292c9547b7fee6159b9933f55cbe Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Fri, 3 May 2024 09:53:17 -0400 Subject: [PATCH 25/27] Download Gecko SDKs as ZIP files --- Dockerfile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6baf7c3b..cecff285 100644 --- a/Dockerfile +++ b/Dockerfile @@ -53,13 +53,15 @@ RUN \ # Gecko SDK 4.4.0 RUN \ - git clone --depth 1 -b v4.4.0 https://github.com/SiliconLabs/gecko_sdk.git gecko_sdk_4.4.0 \ - && rm -rf gecko_sdk_4.4.0/.git + curl -o gecko_sdk_4.4.0.zip -L https://github.com/SiliconLabs/gecko_sdk/releases/download/v4.4.0/gecko-sdk.zip \ + && unzip -d gecko_sdk_4.4.0 gecko_sdk_4.4.0.zip \ + && rm gecko_sdk_4.4.0.zip # Gecko SDK 4.3.1 RUN \ - git clone --depth 1 -b v4.3.1 https://github.com/SiliconLabs/gecko_sdk.git gecko_sdk_4.3.1 \ - && rm -rf gecko_sdk_4.3.1/.git + curl -o gecko_sdk_4.3.1.zip -L https://github.com/SiliconLabs/gecko_sdk/releases/download/v4.3.1/gecko-sdk.zip \ + && unzip -d gecko_sdk_4.3.1 gecko_sdk_4.3.1.zip \ + && rm gecko_sdk_4.3.1.zip ARG USERNAME=builder ARG USER_UID=1000 From db827cfbbd74f49f7b288832af0e1dc4a7bec120 Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Fri, 3 May 2024 09:56:41 -0400 Subject: [PATCH 26/27] Unzip quietly --- Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index cecff285..f26e0a84 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,7 +24,7 @@ RUN \ # is known to be working with Commander_linux_x86_64_1v15p0b1306.tar.bz). RUN \ curl -O https://www.silabs.com/documents/login/software/SimplicityCommander-Linux.zip \ - && unzip SimplicityCommander-Linux.zip \ + && unzip -q SimplicityCommander-Linux.zip \ && tar -C /opt -xjf SimplicityCommander-Linux/Commander_linux_x86_64_*.tar.bz \ && rm -r SimplicityCommander-Linux \ && rm SimplicityCommander-Linux.zip @@ -34,7 +34,7 @@ ENV PATH="$PATH:/opt/commander" # Install Silicon Labs Configurator (slc) RUN \ curl -O https://www.silabs.com/documents/login/software/slc_cli_linux.zip \ - && unzip -d /opt slc_cli_linux.zip \ + && unzip -q -d /opt slc_cli_linux.zip \ && rm slc_cli_linux.zip ENV PATH="$PATH:/opt/slc_cli" @@ -54,13 +54,13 @@ RUN \ # Gecko SDK 4.4.0 RUN \ curl -o gecko_sdk_4.4.0.zip -L https://github.com/SiliconLabs/gecko_sdk/releases/download/v4.4.0/gecko-sdk.zip \ - && unzip -d gecko_sdk_4.4.0 gecko_sdk_4.4.0.zip \ + && unzip -q -d gecko_sdk_4.4.0 gecko_sdk_4.4.0.zip \ && rm gecko_sdk_4.4.0.zip # Gecko SDK 4.3.1 RUN \ curl -o gecko_sdk_4.3.1.zip -L https://github.com/SiliconLabs/gecko_sdk/releases/download/v4.3.1/gecko-sdk.zip \ - && unzip -d gecko_sdk_4.3.1 gecko_sdk_4.3.1.zip \ + && unzip -q -d gecko_sdk_4.3.1 gecko_sdk_4.3.1.zip \ && rm gecko_sdk_4.3.1.zip ARG USERNAME=builder From bcbf8d4f69bdb9879d745c8a068493b932d6e3ea Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Fri, 3 May 2024 10:29:10 -0400 Subject: [PATCH 27/27] Fail if we must build a container in a PR --- .github/workflows/build.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 2fe4e628..1e17b875 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -57,6 +57,11 @@ jobs: fi fi + if [[ $build_image == "true" && $GITHUB_EVENT_NAME == "pull_request" ]]; then + echo "Cannot build a new container within a PR. Please re-run this action after $head_image:$tag_name is built." + exit 1 + fi + echo "build_image=$build_image" >> $GITHUB_OUTPUT echo "tag_name=$tag_name" >> $GITHUB_OUTPUT echo "image_name=$image_name" >> $GITHUB_OUTPUT