Skip to content

Refactor workflows to use single-step multi-platform builds #49

Refactor workflows to use single-step multi-platform builds

Refactor workflows to use single-step multi-platform builds #49

Workflow file for this run

# ESP-IDF Docker Build Workflow
# Builds ESP-IDF development image with pytest, QEMU, and testing tools
#
# Build Strategy:
# - Main repo master: Build + Push to GHCR
# - Main repo dev/PR: Build only (validation)
# - workflow_dispatch: Build on any branch/fork, push only on main repo master
# - Forks: Can test builds, but push is restricted to main repo
# - Multi-platform: Builds for linux/amd64 and linux/arm64 in single job
name: 🐳 ESP-IDF Docker Image
on:
push:
branches: [master, dev]
paths:
- '.github/workflows/esp-idf.yml'
- 'images/esp-idf/**'
- 'images/esp-matter/**'
pull_request:
branches: [master, dev]
paths:
- '.github/workflows/esp-idf.yml'
- 'images/esp-idf/**'
- 'images/esp-matter/**'
workflow_dispatch:
env:
REGISTRY: ghcr.io
ESP_IDF_IMAGE_NAME: jethome-dev-esp-idf
ESP_MATTER_IMAGE_NAME: jethome-dev-esp-matter
jobs:
esp-idf-build:
runs-on: ubuntu-latest
timeout-minutes: 60
if: github.repository_owner == 'jethome-iot' || github.event_name == 'workflow_dispatch'
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
idf_base_tag: ['v5.4.1']
steps:
- name: πŸ“₯ Checkout repository
uses: actions/checkout@v4
- name: πŸ”§ Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: πŸ” Log in to GitHub Container Registry
if: github.repository_owner == 'jethome-iot' && github.ref_name == 'master'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 🏷️ Generate tags
id: tags
run: |
SHA_SHORT=$(echo "${{ github.sha }}" | cut -c1-7)
echo "sha_short=${SHA_SHORT}" >> $GITHUB_OUTPUT
- name: 🐳 Build and push multi-platform image
uses: docker/build-push-action@v5
with:
context: images/esp-idf
platforms: linux/amd64,linux/arm64
push: ${{ github.repository_owner == 'jethome-iot' && github.ref_name == 'master' }}
tags: |
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_IDF_IMAGE_NAME }}:latest
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_IDF_IMAGE_NAME }}:stable
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_IDF_IMAGE_NAME }}:idf-${{ matrix.idf_base_tag }}
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_IDF_IMAGE_NAME }}:sha-${{ steps.tags.outputs.sha_short }}
cache-from: type=gha,scope=${{ env.ESP_IDF_IMAGE_NAME }}
cache-to: type=gha,mode=max,scope=${{ env.ESP_IDF_IMAGE_NAME }}
build-args: |
IDF_BASE_TAG=${{ matrix.idf_base_tag }}
esp-matter-build:
runs-on: ubuntu-latest
timeout-minutes: 60
needs: esp-idf-build
if: false && (github.repository_owner == 'jethome-iot' || github.event_name == 'workflow_dispatch') # Temporarily disabled
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
jethome_idf_base_tag: ['v5.4.1']
esp_matter_version: ['v1.4.2']
steps:
- name: πŸ“₯ Checkout repository
uses: actions/checkout@v4
- name: πŸ”§ Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: πŸ” Log in to GitHub Container Registry
if: github.repository_owner == 'jethome-iot' && github.ref_name == 'master'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 🏷️ Generate tags
id: tags
run: |
SHA_SHORT=$(echo "${{ github.sha }}" | cut -c1-7)
echo "sha_short=${SHA_SHORT}" >> $GITHUB_OUTPUT
- name: 🐳 Build and push multi-platform ESP-Matter image
uses: docker/build-push-action@v5
with:
context: images/esp-matter
platforms: linux/amd64,linux/arm64
push: ${{ github.repository_owner == 'jethome-iot' && github.ref_name == 'master' }}
tags: |
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_MATTER_IMAGE_NAME }}:latest
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_MATTER_IMAGE_NAME }}:stable
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_MATTER_IMAGE_NAME }}:idf-${{ matrix.jethome_idf_base_tag }}-matter-${{ matrix.esp_matter_version }}
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_MATTER_IMAGE_NAME }}:sha-${{ steps.tags.outputs.sha_short }}
cache-from: type=gha,scope=${{ env.ESP_MATTER_IMAGE_NAME }}
cache-to: type=gha,mode=max,scope=${{ env.ESP_MATTER_IMAGE_NAME }}
build-args: |
BASE_IMAGE_TAG=idf-${{ matrix.jethome_idf_base_tag }}
ESP_MATTER_VERSION=${{ matrix.esp_matter_version }}