Skip to content

Commit 48983da

Browse files
committed
Rename and add environment variables for image names in ESP-IDF workflow
- Rename IMAGE_NAME to ESP_IDF_IMAGE_NAME for clarity - Add ESP_MATTER_IMAGE_NAME for ESP-Matter image - Replace all hardcoded image names with environment variables - Single source of truth for image names (DRY principle) - Easier to maintain and update image registry/naming
1 parent 426a5d8 commit 48983da

File tree

2 files changed

+33
-31
lines changed

2 files changed

+33
-31
lines changed

.cursor/rules/github-actions-standards.mdc

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ on:
8989

9090
env:
9191
REGISTRY: ghcr.io
92-
IMAGE_NAME: jethome-dev-<image-name>
92+
<IMAGE_NAME>: jethome-dev-<image-name> # Use uppercase, descriptive name (e.g., ESP_IDF_IMAGE_NAME)
9393

9494
jobs:
9595
<image-name>-build:
@@ -131,9 +131,9 @@ jobs:
131131
platforms: ${{ matrix.platform }}
132132
push: ${{ github.ref_name == 'master' }}
133133
tags: |
134-
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:<prefix>-${{ matrix.version }}-${{ steps.platform.outputs.tag }}
135-
cache-from: type=gha,scope=${{ env.IMAGE_NAME }}-${{ steps.platform.outputs.tag }}
136-
cache-to: type=gha,mode=max,scope=${{ env.IMAGE_NAME }}-${{ steps.platform.outputs.tag }}
134+
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.<IMAGE_NAME> }}:<prefix>-${{ matrix.version }}-${{ steps.platform.outputs.tag }}
135+
cache-from: type=gha,scope=${{ env.<IMAGE_NAME> }}-${{ steps.platform.outputs.tag }}
136+
cache-to: type=gha,mode=max,scope=${{ env.<IMAGE_NAME> }}-${{ steps.platform.outputs.tag }}
137137
build-args: |
138138
VERSION=${{ matrix.version }}
139139

@@ -165,18 +165,19 @@ jobs:
165165

166166
- name: 🎯 Create multi-arch manifest
167167
run: |
168-
docker buildx imagetools create -t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest \
169-
-t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:stable \
170-
-t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:<prefix>-${{ matrix.version }} \
171-
-t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ steps.tags.outputs.date_tag }} \
172-
-t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:sha-${{ steps.tags.outputs.sha_short }} \
173-
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:<prefix>-${{ matrix.version }}-linux-amd64 \
174-
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:<prefix>-${{ matrix.version }}-linux-arm64
168+
docker buildx imagetools create -t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.<IMAGE_NAME> }}:latest \
169+
-t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.<IMAGE_NAME> }}:stable \
170+
-t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.<IMAGE_NAME> }}:<prefix>-${{ matrix.version }} \
171+
-t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.<IMAGE_NAME> }}:${{ steps.tags.outputs.date_tag }} \
172+
-t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.<IMAGE_NAME> }}:sha-${{ steps.tags.outputs.sha_short }} \
173+
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.<IMAGE_NAME> }}:<prefix>-${{ matrix.version }}-linux-amd64 \
174+
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.<IMAGE_NAME> }}:<prefix>-${{ matrix.version }}-linux-arm64
175175
```
176176

177177
**Critical Details:**
178178
- **Job naming**: Use `<image-name>-build` and `<image-name>-manifest` pattern (e.g., `esp-idf-build`, `esp-idf-manifest`)
179179
- **Benefits of image-first naming**: Jobs for same image group together in GitHub UI when sorted alphabetically
180+
- **Image name variables**: Use descriptive uppercase names like `ESP_IDF_IMAGE_NAME`, not generic `IMAGE_NAME`
180181
- Matrix builds both platforms in parallel for faster CI
181182
- Platform-specific images tagged with arch suffix (e.g., `pio-6.1.18-linux-amd64`)
182183
- Manifest job combines platform images into multi-arch manifest

.github/workflows/esp-idf.yml

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ on:
1717

1818
env:
1919
REGISTRY: ghcr.io
20-
IMAGE_NAME: jethome-dev-esp-idf
20+
ESP_IDF_IMAGE_NAME: jethome-dev-esp-idf
21+
ESP_MATTER_IMAGE_NAME: jethome-dev-esp-matter
2122

2223
jobs:
2324
esp-idf-build:
@@ -59,9 +60,9 @@ jobs:
5960
platforms: ${{ matrix.platform }}
6061
push: ${{ github.ref_name == 'master' }}
6162
tags: |
62-
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:idf-${{ matrix.idf_base_tag }}-${{ steps.platform.outputs.tag }}
63-
cache-from: type=gha,scope=${{ env.IMAGE_NAME }}-${{ steps.platform.outputs.tag }}
64-
cache-to: type=gha,mode=max,scope=${{ env.IMAGE_NAME }}-${{ steps.platform.outputs.tag }}
63+
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_IDF_IMAGE_NAME }}:idf-${{ matrix.idf_base_tag }}-${{ steps.platform.outputs.tag }}
64+
cache-from: type=gha,scope=${{ env.ESP_IDF_IMAGE_NAME }}-${{ steps.platform.outputs.tag }}
65+
cache-to: type=gha,mode=max,scope=${{ env.ESP_IDF_IMAGE_NAME }}-${{ steps.platform.outputs.tag }}
6566
build-args: |
6667
IDF_BASE_TAG=${{ matrix.idf_base_tag }}
6768
@@ -93,13 +94,13 @@ jobs:
9394
9495
- name: 🎯 Create multi-arch manifest
9596
run: |
96-
docker buildx imagetools create -t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest \
97-
-t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:stable \
98-
-t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:idf-${{ matrix.idf_base_tag }} \
99-
-t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ steps.tags.outputs.date_tag }} \
100-
-t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:sha-${{ steps.tags.outputs.sha_short }} \
101-
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:idf-${{ matrix.idf_base_tag }}-linux-amd64 \
102-
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:idf-${{ matrix.idf_base_tag }}-linux-arm64
97+
docker buildx imagetools create -t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_IDF_IMAGE_NAME }}:latest \
98+
-t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_IDF_IMAGE_NAME }}:stable \
99+
-t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_IDF_IMAGE_NAME }}:idf-${{ matrix.idf_base_tag }} \
100+
-t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_IDF_IMAGE_NAME }}:${{ steps.tags.outputs.date_tag }} \
101+
-t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_IDF_IMAGE_NAME }}:sha-${{ steps.tags.outputs.sha_short }} \
102+
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_IDF_IMAGE_NAME }}:idf-${{ matrix.idf_base_tag }}-linux-amd64 \
103+
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_IDF_IMAGE_NAME }}:idf-${{ matrix.idf_base_tag }}-linux-arm64
103104
104105
esp-matter-build:
105106
runs-on: ubuntu-latest
@@ -142,7 +143,7 @@ jobs:
142143
platforms: ${{ matrix.platform }}
143144
push: ${{ github.ref_name == 'master' }}
144145
tags: |
145-
${{ env.REGISTRY }}/${{ github.repository_owner }}/jethome-dev-esp-matter:idf-${{ matrix.jethome_idf_base_tag }}-matter-${{ matrix.esp_matter_version }}-${{ steps.platform.outputs.tag }}
146+
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_MATTER_IMAGE_NAME }}:idf-${{ matrix.jethome_idf_base_tag }}-matter-${{ matrix.esp_matter_version }}-${{ steps.platform.outputs.tag }}
146147
cache-from: type=gha,scope=esp-matter-${{ steps.platform.outputs.tag }}
147148
cache-to: type=gha,mode=max,scope=esp-matter-${{ steps.platform.outputs.tag }}
148149
build-args: |
@@ -178,11 +179,11 @@ jobs:
178179
179180
- name: 🎯 Create multi-arch manifest for ESP-Matter
180181
run: |
181-
docker buildx imagetools create -t ${{ env.REGISTRY }}/${{ github.repository_owner }}/jethome-dev-esp-matter:latest \
182-
-t ${{ env.REGISTRY }}/${{ github.repository_owner }}/jethome-dev-esp-matter:stable \
183-
-t ${{ env.REGISTRY }}/${{ github.repository_owner }}/jethome-dev-esp-matter:idf-${{ matrix.jethome_idf_base_tag }}-matter-${{ matrix.esp_matter_version }} \
184-
-t ${{ env.REGISTRY }}/${{ github.repository_owner }}/jethome-dev-esp-matter:matter-${{ matrix.esp_matter_version }} \
185-
-t ${{ env.REGISTRY }}/${{ github.repository_owner }}/jethome-dev-esp-matter:${{ steps.tags.outputs.date_tag }} \
186-
-t ${{ env.REGISTRY }}/${{ github.repository_owner }}/jethome-dev-esp-matter:sha-${{ steps.tags.outputs.sha_short }} \
187-
${{ env.REGISTRY }}/${{ github.repository_owner }}/jethome-dev-esp-matter:idf-${{ matrix.jethome_idf_base_tag }}-matter-${{ matrix.esp_matter_version }}-linux-amd64 \
188-
${{ env.REGISTRY }}/${{ github.repository_owner }}/jethome-dev-esp-matter:idf-${{ matrix.jethome_idf_base_tag }}-matter-${{ matrix.esp_matter_version }}-linux-arm64
182+
docker buildx imagetools create -t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_MATTER_IMAGE_NAME }}:latest \
183+
-t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_MATTER_IMAGE_NAME }}:stable \
184+
-t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_MATTER_IMAGE_NAME }}:idf-${{ matrix.jethome_idf_base_tag }}-matter-${{ matrix.esp_matter_version }} \
185+
-t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_MATTER_IMAGE_NAME }}:matter-${{ matrix.esp_matter_version }} \
186+
-t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_MATTER_IMAGE_NAME }}:${{ steps.tags.outputs.date_tag }} \
187+
-t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_MATTER_IMAGE_NAME }}:sha-${{ steps.tags.outputs.sha_short }} \
188+
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_MATTER_IMAGE_NAME }}:idf-${{ matrix.jethome_idf_base_tag }}-matter-${{ matrix.esp_matter_version }}-linux-amd64 \
189+
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_MATTER_IMAGE_NAME }}:idf-${{ matrix.jethome_idf_base_tag }}-matter-${{ matrix.esp_matter_version }}-linux-arm64

0 commit comments

Comments
 (0)