From 1ecad97dc7a378f67bb9c4b5c0e7fb97202dbdab Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sun, 2 Nov 2025 18:55:55 +0100 Subject: [PATCH 1/4] Only push containers if on main branch --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ff337ce..b8be3bc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,7 +49,7 @@ jobs: with: context: .devcontainer file: .devcontainer/Dockerfile - push: true + push: ${{ github.ref == 'refs/heads/main' }} tags: ${{ steps.set_output.outputs.container_name }} cache-from: | type=registry,ref=${{ steps.set_output.outputs.container_name }}-cache From d00ef46911dcd93bec4ff30c081171e04053b2c2 Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sun, 2 Nov 2025 19:02:21 +0100 Subject: [PATCH 2/4] Always use main container --- .github/workflows/ci.yml | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b8be3bc..ea78c72 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,11 +38,9 @@ jobs: - name: Set container name as output id: set_output run: | - BRANCH=$(echo "${GITHUB_REF}" | sed 's|refs/heads/||' | tr '[:upper:]' '[:lower:]') REPO=$(echo "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]') - CONTAINER_NAME="ghcr.io/${REPO}/devcontainer:${BRANCH//\//-}" + CONTAINER_NAME="ghcr.io/${REPO}/devcontainer:main" echo "container_name=$CONTAINER_NAME" >> $GITHUB_OUTPUT - echo "container_without_tag=ghcr.io/${REPO}/devcontainer" >> $GITHUB_OUTPUT - name: Build and push Docker image uses: docker/build-push-action@v2 @@ -51,17 +49,15 @@ jobs: file: .devcontainer/Dockerfile push: ${{ github.ref == 'refs/heads/main' }} tags: ${{ steps.set_output.outputs.container_name }} - cache-from: | - type=registry,ref=${{ steps.set_output.outputs.container_name }}-cache - type=registry,ref=${{ steps.set_output.outputs.container_without_tag }}:main-cache + cache-from: type=registry,ref=${{ steps.set_output.outputs.container_name }}-cache cache-to: type=registry,ref=${{ steps.set_output.outputs.container_name }}-cache,mode=max test: name: Testing - needs: [container] runs-on: ubuntu-latest + needs: [container] container: - image: ${{ needs.container.outputs.container_name }} + image: ghcr.io/${{ github.repository }}/devcontainer:main permissions: contents: read issues: write @@ -88,10 +84,10 @@ jobs: fmt: name: Check formatting - needs: [container] runs-on: ubuntu-latest + needs: [container] container: - image: ${{ needs.container.outputs.container_name }} + image: ghcr.io/${{ github.repository }}/devcontainer:main steps: - name: Checkout uses: actions/checkout@v4 @@ -103,10 +99,10 @@ jobs: kani: name: Kani verification - needs: [container] runs-on: ubuntu-latest + needs: [container] container: - image: ${{ needs.container.outputs.container_name }} + image: ghcr.io/${{ github.repository }}/devcontainer:main steps: - name: Checkout uses: actions/checkout@v4 @@ -121,10 +117,10 @@ jobs: build-stm32-l4r5zi-def: name: Build for the STM32 Nucleo L4R5ZI - needs: [container] runs-on: ubuntu-latest + needs: [container] container: - image: ${{ needs.container.outputs.container_name }} + image: ghcr.io/${{ github.repository }}/devcontainer:main steps: - name: Checkout uses: actions/checkout@v4 From e2cc068f2285ffa7de10c57a990cde4629bd5305 Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sun, 2 Nov 2025 19:05:21 +0100 Subject: [PATCH 3/4] Fix image --- .github/workflows/ci.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ea78c72..dc4562f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,6 +41,7 @@ jobs: REPO=$(echo "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]') CONTAINER_NAME="ghcr.io/${REPO}/devcontainer:main" echo "container_name=$CONTAINER_NAME" >> $GITHUB_OUTPUT + echo "container_without_tag=ghcr.io/${REPO}/devcontainer" >> $GITHUB_OUTPUT - name: Build and push Docker image uses: docker/build-push-action@v2 @@ -57,7 +58,7 @@ jobs: runs-on: ubuntu-latest needs: [container] container: - image: ghcr.io/${{ github.repository }}/devcontainer:main + image: ${{ needs.container.outputs.container_name }}:main permissions: contents: read issues: write @@ -87,7 +88,7 @@ jobs: runs-on: ubuntu-latest needs: [container] container: - image: ghcr.io/${{ github.repository }}/devcontainer:main + image: ${{ needs.container.outputs.container_name }}:main steps: - name: Checkout uses: actions/checkout@v4 @@ -102,7 +103,7 @@ jobs: runs-on: ubuntu-latest needs: [container] container: - image: ghcr.io/${{ github.repository }}/devcontainer:main + image: ${{ needs.container.outputs.container_name }}:main steps: - name: Checkout uses: actions/checkout@v4 @@ -120,7 +121,7 @@ jobs: runs-on: ubuntu-latest needs: [container] container: - image: ghcr.io/${{ github.repository }}/devcontainer:main + image: ${{ needs.container.outputs.container_name }}:main steps: - name: Checkout uses: actions/checkout@v4 From acb8c14d68a87a88a0ba364b7790f6c73b23df48 Mon Sep 17 00:00:00 2001 From: xarantolus Date: Sun, 2 Nov 2025 19:06:42 +0100 Subject: [PATCH 4/4] Fix tag --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dc4562f..42f467b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,7 +58,7 @@ jobs: runs-on: ubuntu-latest needs: [container] container: - image: ${{ needs.container.outputs.container_name }}:main + image: ${{ needs.container.outputs.container_name }} permissions: contents: read issues: write @@ -88,7 +88,7 @@ jobs: runs-on: ubuntu-latest needs: [container] container: - image: ${{ needs.container.outputs.container_name }}:main + image: ${{ needs.container.outputs.container_name }} steps: - name: Checkout uses: actions/checkout@v4 @@ -103,7 +103,7 @@ jobs: runs-on: ubuntu-latest needs: [container] container: - image: ${{ needs.container.outputs.container_name }}:main + image: ${{ needs.container.outputs.container_name }} steps: - name: Checkout uses: actions/checkout@v4 @@ -121,7 +121,7 @@ jobs: runs-on: ubuntu-latest needs: [container] container: - image: ${{ needs.container.outputs.container_name }}:main + image: ${{ needs.container.outputs.container_name }} steps: - name: Checkout uses: actions/checkout@v4