Skip to content

Commit 55820ac

Browse files
committed
Align container builds
For maintainability
1 parent 6cbd79a commit 55820ac

File tree

5 files changed

+71
-49
lines changed

5 files changed

+71
-49
lines changed

.github/workflows/devcontainer-all.yaml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ name: Build Dev Container for all platforms
66
env:
77
CONTAINER_REPO: ghcr.io
88
CONTAINER_NAME: dev-container-all
9-
CONTAINER_SRC_FILE: .devcontainer/All/Dockerfile.All.SRC
9+
CONTAINER_SOURCE_FILE: .devcontainer/All/Dockerfile.All.SRC
10+
CONTAINER_VERSION_FILE: .devcontainer/All/Dockerfile.All
1011

1112
on:
1213
push:
@@ -21,34 +22,38 @@ jobs:
2122
build:
2223
if: ${{ vars.PUBLISH_DOCKER_IMAGE == 'true' }}
2324
runs-on: ubuntu-latest
24-
steps:
25+
permissions:
26+
contents: read
27+
packages: write
2528

29+
steps:
2630
- name: Checkout Repository
2731
uses: actions/checkout@v4
2832

2933
- name: Get container version
34+
shell: pwsh
3035
run: |
31-
$dockerfileContent = Get-Content(".devcontainer/All/Dockerfile.All")
36+
$dockerfileContent = Get-Content("${{ env.CONTAINER_VERSION_FILE }}")
3237
$dockerfileContent -match '(?<=\:)(?:[v]\d+.\d+)'
3338
$containerVersion = $Matches[0].ToString()
3439
echo "GCR_VERSION=$containerVersion" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
35-
shell: pwsh
3640
3741
- name: Set up Docker Buildx
38-
uses: docker/setup-buildx-action@v2
42+
uses: docker/setup-buildx-action@v3
3943

4044
- name: Login to GitHub Container Registry
41-
uses: docker/login-action@v2
45+
if: ${{ github.event_name != 'pull_request' }}
46+
uses: docker/login-action@v3
4247
with:
43-
registry: ghcr.io
48+
registry: ${{ env.CONTAINER_REPO }}
4449
username: ${{ github.repository_owner }}
45-
password: ${{ secrets.CONTAINER_BUILD_TOKEN }}
50+
password: ${{ secrets.GITHUB_TOKEN }}
4651

4752
- name: Build and Push Docker Image
4853
uses: docker/build-push-action@v5
4954
with:
50-
file: ${{ env.CONTAINER_SRC_FILE }}
51-
push: true # Will only build if this is not here
55+
file: ${{ env.CONTAINER_SOURCE_FILE }}
56+
push: ${{ github.event_name != 'pull_request' }}
5257
tags: |
5358
${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:${{ env.GCR_VERSION }}
5459
${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:latest

.github/workflows/devcontainer-azurertos.yaml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ name: Build Dev Container for Azure RTOS
66
env:
77
CONTAINER_REPO: ghcr.io
88
CONTAINER_NAME: dev-container-azure-rtos
9-
CONTAINER_SRC_FILE: .devcontainer/AzureRTOS/Dockerfile.AzureRTOS.SRC
9+
CONTAINER_SOURCE_FILE: .devcontainer/AzureRTOS/Dockerfile.AzureRTOS.SRC
10+
CONTAINER_VERSION_FILE: .devcontainer/AzureRTOS/Dockerfile.AzureRTOS
1011

1112
on:
1213
push:
@@ -21,34 +22,38 @@ jobs:
2122
build:
2223
if: ${{ vars.PUBLISH_DOCKER_IMAGE == 'true' }}
2324
runs-on: ubuntu-latest
24-
steps:
25+
permissions:
26+
contents: read
27+
packages: write
2528

29+
steps:
2630
- name: Checkout Repository
2731
uses: actions/checkout@v4
2832

2933
- name: Get container version
34+
shell: pwsh
3035
run: |
31-
$dockerfileContent = Get-Content(".devcontainer/AzureRTOS/Dockerfile.AzureRTOS")
36+
$dockerfileContent = Get-Content("${{ env.CONTAINER_VERSION_FILE }}")
3237
$dockerfileContent -match '(?<=\:)(?:[v]\d+.\d+)'
3338
$containerVersion = $Matches[0].ToString()
3439
echo "GCR_VERSION=$containerVersion" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
35-
shell: pwsh
3640
3741
- name: Set up Docker Buildx
38-
uses: docker/setup-buildx-action@v2
42+
uses: docker/setup-buildx-action@v3
3943

4044
- name: Login to GitHub Container Registry
41-
uses: docker/login-action@v2
45+
if: ${{ github.event_name != 'pull_request' }}
46+
uses: docker/login-action@v3
4247
with:
43-
registry: ghcr.io
48+
registry: ${{ env.CONTAINER_REPO }}
4449
username: ${{ github.repository_owner }}
45-
password: ${{ secrets.CONTAINER_BUILD_TOKEN }}
50+
password: ${{ secrets.GITHUB_TOKEN }}
4651

4752
- name: Build and Push Docker Image
4853
uses: docker/build-push-action@v5
4954
with:
50-
file: ${{ env.CONTAINER_SRC_FILE }}
51-
push: true # Will only build if this is not here
55+
file: ${{ env.CONTAINER_SOURCE_FILE }}
56+
push: ${{ github.event_name != 'pull_request' }}
5257
tags: |
5358
${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:${{ env.GCR_VERSION }}
5459
${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:latest

.github/workflows/devcontainer-chibios.yaml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ name: Build Dev Container for ChibiOS
66
env:
77
CONTAINER_REPO: ghcr.io
88
CONTAINER_NAME: dev-container-chibios
9-
CONTAINER_SRC_FILE: .devcontainer/ChibiOS/Dockerfile.ChibiOS.SRC
9+
CONTAINER_SOURCE_FILE: .devcontainer/ChibiOS/Dockerfile.ChibiOS.SRC
10+
CONTAINER_VERSION_FILE: .devcontainer/ChibiOS/Dockerfile.ChibiOS
1011

1112
on:
1213
push:
@@ -21,34 +22,38 @@ jobs:
2122
build:
2223
if: ${{ vars.PUBLISH_DOCKER_IMAGE == 'true' }}
2324
runs-on: ubuntu-latest
24-
steps:
25+
permissions:
26+
contents: read
27+
packages: write
2528

29+
steps:
2630
- name: Checkout Repository
2731
uses: actions/checkout@v4
2832

2933
- name: Get container version
34+
shell: pwsh
3035
run: |
31-
$dockerfileContent = Get-Content(".devcontainer/ChibiOS/Dockerfile.ChibiOS")
36+
$dockerfileContent = Get-Content("${{ env.CONTAINER_VERSION_FILE }}")
3237
$dockerfileContent -match '(?<=\:)(?:[v]\d+.\d+)'
3338
$containerVersion = $Matches[0].ToString()
3439
echo "GCR_VERSION=$containerVersion" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
35-
shell: pwsh
3640
3741
- name: Set up Docker Buildx
38-
uses: docker/setup-buildx-action@v2
42+
uses: docker/setup-buildx-action@v3
3943

4044
- name: Login to GitHub Container Registry
41-
uses: docker/login-action@v2
45+
if: ${{ github.event_name != 'pull_request' }}
46+
uses: docker/login-action@v3
4247
with:
43-
registry: ghcr.io
48+
registry: ${{ env.CONTAINER_REPO }}
4449
username: ${{ github.repository_owner }}
45-
password: ${{ secrets.CONTAINER_BUILD_TOKEN }}
50+
password: ${{ secrets.GITHUB_TOKEN }}
4651

4752
- name: Build and Push Docker Image
4853
uses: docker/build-push-action@v5
4954
with:
50-
file: ${{ env.CONTAINER_SRC_FILE }}
51-
push: true # Will only build if this is not here
55+
file: ${{ env.CONTAINER_SOURCE_FILE }}
56+
push: ${{ github.event_name != 'pull_request' }}
5257
tags: |
5358
${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:${{ env.GCR_VERSION }}
5459
${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:latest

.github/workflows/devcontainer-esp32.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ name: Build Dev Container for ESP32
66
env:
77
CONTAINER_REPO: ghcr.io
88
CONTAINER_NAME: dev-container-esp32
9-
CONTAINER_SRC_FILE: .devcontainer/ESP32/Dockerfile.ESP32.SRC
9+
CONTAINER_SOURCE_FILE: .devcontainer/ESP32/Dockerfile.ESP32.SRC
10+
CONTAINER_VERSION_FILE: .devcontainer/ESP32/Dockerfile.ESP32
1011

1112
on:
1213
push:
@@ -27,28 +28,29 @@ jobs:
2728
uses: actions/checkout@v4
2829

2930
- name: Get container version
31+
shell: pwsh
3032
run: |
31-
$dockerfileContent = Get-Content(".devcontainer/ESP32/Dockerfile.ESP32")
33+
$dockerfileContent = Get-Content("${{ env.CONTAINER_VERSION_FILE }}")
3234
$dockerfileContent -match '(?<=\:)(?:[v]\d+.\d+)'
3335
$containerVersion = $Matches[0].ToString()
3436
echo "GCR_VERSION=$containerVersion" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
35-
shell: pwsh
3637
3738
- name: Set up Docker Buildx
38-
uses: docker/setup-buildx-action@v2
39+
uses: docker/setup-buildx-action@v3
3940

4041
- name: Login to GitHub Container Registry
41-
uses: docker/login-action@v2
42+
if: ${{ github.event_name != 'pull_request' }}
43+
uses: docker/login-action@v3
4244
with:
43-
registry: ghcr.io
45+
registry: ${{ env.CONTAINER_REPO }}
4446
username: ${{ github.repository_owner }}
45-
password: ${{ secrets.CONTAINER_BUILD_TOKEN }}
47+
password: ${{ secrets.GITHUB_TOKEN }}
4648

4749
- name: Build and Push Docker Image
4850
uses: docker/build-push-action@v5
4951
with:
50-
file: ${{ env.CONTAINER_SRC_FILE }}
51-
push: true # Will only build if this is not here
52+
file: ${{ env.CONTAINER_SOURCE_FILE }}
53+
push: ${{ github.event_name != 'pull_request' }}
5254
tags: |
5355
${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:${{ env.GCR_VERSION }}
5456
${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:latest

.github/workflows/devcontainer-ti.yaml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ name: Build Dev Container for TI
66
env:
77
CONTAINER_REPO: ghcr.io
88
CONTAINER_NAME: dev-container-ti
9-
CONTAINER_SRC_FILE: .devcontainer/TI/Dockerfile.TI.SRC
9+
CONTAINER_SOURCE_FILE: .devcontainer/TI/Dockerfile.TI.SRC
10+
CONTAINER_VERSION_FILE: .devcontainer/TI/Dockerfile.TI
1011

1112
on:
1213
push:
@@ -21,34 +22,38 @@ jobs:
2122
build:
2223
if: ${{ vars.PUBLISH_DOCKER_IMAGE == 'true' }}
2324
runs-on: ubuntu-latest
24-
steps:
25+
permissions:
26+
contents: read
27+
packages: write
2528

29+
steps:
2630
- name: Checkout Repository
2731
uses: actions/checkout@v4
2832

2933
- name: Get container version
34+
shell: pwsh
3035
run: |
31-
$dockerfileContent = Get-Content(".devcontainer/TI/Dockerfile.TI")
36+
$dockerfileContent = Get-Content("${{ env.CONTAINER_VERSION_FILE }}")
3237
$dockerfileContent -match '(?<=\:)(?:[v]\d+.\d+)'
3338
$containerVersion = $Matches[0].ToString()
3439
echo "GCR_VERSION=$containerVersion" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
35-
shell: pwsh
3640
3741
- name: Set up Docker Buildx
38-
uses: docker/setup-buildx-action@v2
42+
uses: docker/setup-buildx-action@v3
3943

4044
- name: Login to GitHub Container Registry
41-
uses: docker/login-action@v2
45+
if: ${{ github.event_name != 'pull_request' }}
46+
uses: docker/login-action@v3
4247
with:
43-
registry: ghcr.io
48+
registry: ${{ env.CONTAINER_REPO }}
4449
username: ${{ github.repository_owner }}
45-
password: ${{ secrets.CONTAINER_BUILD_TOKEN }}
50+
password: ${{ secrets.GITHUB_TOKEN }}
4651

4752
- name: Build and Push Docker Image
4853
uses: docker/build-push-action@v5
4954
with:
50-
file: ${{ env.CONTAINER_SRC_FILE }}
51-
push: true # Will only build if this is not here
55+
file: ${{ env.CONTAINER_SOURCE_FILE }}
56+
push: ${{ github.event_name != 'pull_request' }}
5257
tags: |
5358
${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:${{ env.GCR_VERSION }}
5459
${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:latest

0 commit comments

Comments
 (0)