Fix cache scope to use image name environment variables #44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ESP-IDF Docker Build Workflow | |
| # Builds ESP-IDF development image with pytest, QEMU, and testing tools | |
| name: π³ ESP-IDF Docker Image | |
| on: | |
| push: | |
| branches: [master, dev] | |
| paths: | |
| - '.github/workflows/esp-idf.yml' | |
| - 'images/esp-idf/**' | |
| pull_request: | |
| branches: [master, dev] | |
| paths: | |
| - '.github/workflows/esp-idf.yml' | |
| - 'images/esp-idf/**' | |
| 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 | |
| if: github.repository_owner == 'jethome-iot' | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| matrix: | |
| platform: [linux/amd64, linux/arm64] | |
| 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.ref_name == 'master' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: π·οΈ Prepare platform tag | |
| id: platform | |
| run: | | |
| PLATFORM_PAIR=${{ matrix.platform }} | |
| PLATFORM_TAG=$(echo $PLATFORM_PAIR | sed 's/\//-/g') | |
| echo "tag=${PLATFORM_TAG}" >> $GITHUB_OUTPUT | |
| - name: π³ Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: images/esp-idf | |
| platforms: ${{ matrix.platform }} | |
| push: ${{ github.ref_name == 'master' }} | |
| tags: | | |
| ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_IDF_IMAGE_NAME }}:idf-${{ matrix.idf_base_tag }}-${{ steps.platform.outputs.tag }} | |
| cache-from: type=gha,scope=${{ env.ESP_IDF_IMAGE_NAME }}-${{ steps.platform.outputs.tag }} | |
| cache-to: type=gha,mode=max,scope=${{ env.ESP_IDF_IMAGE_NAME }}-${{ steps.platform.outputs.tag }} | |
| build-args: | | |
| IDF_BASE_TAG=${{ matrix.idf_base_tag }} | |
| esp-idf-manifest: | |
| runs-on: ubuntu-latest | |
| needs: esp-idf-build | |
| if: github.repository_owner == 'jethome-iot' && github.ref_name == 'master' | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| matrix: | |
| idf_base_tag: ['v5.4.1'] | |
| steps: | |
| - name: π Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: π·οΈ Generate version and date tags | |
| id: tags | |
| run: | | |
| SHA_SHORT=$(echo "${{ github.sha }}" | cut -c1-7) | |
| DATE_TAG=$(date +%Y.%m.%d) | |
| echo "sha_short=${SHA_SHORT}" >> $GITHUB_OUTPUT | |
| echo "date_tag=${DATE_TAG}" >> $GITHUB_OUTPUT | |
| - name: π― Create multi-arch manifest | |
| run: | | |
| docker buildx imagetools create -t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_IDF_IMAGE_NAME }}:latest \ | |
| -t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_IDF_IMAGE_NAME }}:stable \ | |
| -t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_IDF_IMAGE_NAME }}:idf-${{ matrix.idf_base_tag }} \ | |
| -t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_IDF_IMAGE_NAME }}:${{ steps.tags.outputs.date_tag }} \ | |
| -t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_IDF_IMAGE_NAME }}:sha-${{ steps.tags.outputs.sha_short }} \ | |
| ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_IDF_IMAGE_NAME }}:idf-${{ matrix.idf_base_tag }}-linux-amd64 \ | |
| ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_IDF_IMAGE_NAME }}:idf-${{ matrix.idf_base_tag }}-linux-arm64 | |
| esp-matter-build: | |
| runs-on: ubuntu-latest | |
| needs: esp-idf-build | |
| if: false && github.repository_owner == 'jethome-iot' # Temporarily disabled | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| matrix: | |
| platform: [linux/amd64, linux/arm64] | |
| 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.ref_name == 'master' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: π·οΈ Prepare platform tag | |
| id: platform | |
| run: | | |
| PLATFORM_PAIR=${{ matrix.platform }} | |
| PLATFORM_TAG=$(echo $PLATFORM_PAIR | sed 's/\//-/g') | |
| echo "tag=${PLATFORM_TAG}" >> $GITHUB_OUTPUT | |
| - name: π³ Build and push ESP-Matter Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: images/esp-matter | |
| platforms: ${{ matrix.platform }} | |
| push: ${{ github.ref_name == 'master' }} | |
| tags: | | |
| ${{ 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 }} | |
| cache-from: type=gha,scope=${{ env.ESP_MATTER_IMAGE_NAME }}-${{ steps.platform.outputs.tag }} | |
| cache-to: type=gha,mode=max,scope=${{ env.ESP_MATTER_IMAGE_NAME }}-${{ steps.platform.outputs.tag }} | |
| build-args: | | |
| BASE_IMAGE_TAG=idf-${{ matrix.jethome_idf_base_tag }}-${{ steps.platform.outputs.tag }} | |
| ESP_MATTER_VERSION=${{ matrix.esp_matter_version }} | |
| esp-matter-manifest: | |
| runs-on: ubuntu-latest | |
| needs: esp-matter-build | |
| if: false && github.repository_owner == 'jethome-iot' && github.ref_name == 'master' # Temporarily disabled | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| matrix: | |
| jethome_idf_base_tag: ['v5.4.1'] | |
| esp_matter_version: ['v1.4.2'] | |
| steps: | |
| - name: π Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: π·οΈ Generate version and date tags | |
| id: tags | |
| run: | | |
| SHA_SHORT=$(echo "${{ github.sha }}" | cut -c1-7) | |
| DATE_TAG=$(date +%Y.%m.%d) | |
| echo "sha_short=${SHA_SHORT}" >> $GITHUB_OUTPUT | |
| echo "date_tag=${DATE_TAG}" >> $GITHUB_OUTPUT | |
| - name: π― Create multi-arch manifest for ESP-Matter | |
| run: | | |
| docker buildx imagetools create -t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_MATTER_IMAGE_NAME }}:latest \ | |
| -t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_MATTER_IMAGE_NAME }}:stable \ | |
| -t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_MATTER_IMAGE_NAME }}:idf-${{ matrix.jethome_idf_base_tag }}-matter-${{ matrix.esp_matter_version }} \ | |
| -t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_MATTER_IMAGE_NAME }}:matter-${{ matrix.esp_matter_version }} \ | |
| -t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_MATTER_IMAGE_NAME }}:${{ steps.tags.outputs.date_tag }} \ | |
| -t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_MATTER_IMAGE_NAME }}:sha-${{ steps.tags.outputs.sha_short }} \ | |
| ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_MATTER_IMAGE_NAME }}:idf-${{ matrix.jethome_idf_base_tag }}-matter-${{ matrix.esp_matter_version }}-linux-amd64 \ | |
| ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.ESP_MATTER_IMAGE_NAME }}:idf-${{ matrix.jethome_idf_base_tag }}-matter-${{ matrix.esp_matter_version }}-linux-arm64 |