Add Manyfold add-on #1128
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
| # yamllint disable rule:line-length | |
| # shellcheck disable=SC2043 | |
| --- | |
| name: PR Check Build | |
| on: | |
| pull_request: | |
| branches: | |
| - master | |
| jobs: | |
| # 1. Detect which add-on folders changed (by config.json|yaml|yml modification) | |
| check-addon-changes: | |
| if: ${{ github.repository_owner == 'alexbelgium' && !contains(github.event.head_commit.message, 'nobuild') }} | |
| runs-on: ubuntu-latest | |
| outputs: | |
| changedAddons: ${{ steps.find_addons.outputs.changed_addons }} | |
| changedChangelogFiles: ${{ steps.changed-files.outputs.changelogs_files }} | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v6 | |
| - name: Find changed addon directories | |
| id: find_addons | |
| run: | | |
| git fetch origin "${{ github.event.before }}" || true | |
| changed_config_files=$(git diff --name-only "${{ github.event.before }}" "${{ github.sha }}" | grep -E '^[^/]+/config\.(json|ya?ml)$' || true) | |
| echo "Changed config files:" | |
| echo "$changed_config_files" | |
| changed_addons=$(printf '%s' "$changed_config_files" | awk -F/ '{print $1}' | sort -u | jq -R -s -c 'split("\n") | map(select(length > 0))') | |
| echo "Changed addons: $changed_addons" | |
| echo "changed_addons=$changed_addons" >> "$GITHUB_OUTPUT" | |
| - name: Find changelog | |
| id: changed-files | |
| run: | | |
| git fetch origin "${{ github.event.before }}" || true | |
| changed_changelog_files=$(git diff --name-only "${{ github.event.before }}" "${{ github.sha }}" | grep -iE '^([^/]+/)?changelog\.(md|txt|ya?ml|json)$' || true) | |
| echo "$changed_changelog_files" | |
| changed_config_files=$(git diff --name-only "${{ github.event.before }}" "${{ github.sha }}" | grep -E '^[^/]+/config\.(json|ya?ml)$' || true) | |
| echo "$changed_config_files" | |
| all_changed_files=$(echo -e "$changed_config_files\n$changed_changelog_files" | sort -u) | |
| changed_addons=$(printf '%s' "$all_changed_files" | awk -F/ '{print $1}' | sort -u | jq -R -s -c 'split("\n") | map(select(length > 0))') | |
| echo "Changed addons: $changed_addons" | |
| echo "changed_addons=$changed_addons" >> "$GITHUB_OUTPUT" | |
| check-changed-changelog: | |
| name: Check if CHANGELOG.md changed | |
| needs: check-addon-changes | |
| if: ${{ needs.check-addon-changes.outputs.changedAddons != '[]' }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| addon: ${{ fromJSON(needs.check-addon-changes.outputs.changedAddons) }} | |
| steps: | |
| - name: ๐ Check for updated CHANGELOG.md | |
| shell: bash | |
| run: | | |
| # shellcheck disable=SC2076,SC2059 | |
| if [[ ! "${{ needs.check-addon-changes.outputs.changedChangelogFiles }}" =~ "${{ matrix.addon }}/CHANGELOG.md" ]]; then | |
| echo "::error::No new entries in ${{ matrix.addon }} CHANGELOG.md file!" | |
| exit 1 | |
| fi | |
| addon-linter: | |
| name: Addon linting | |
| needs: check-addon-changes | |
| if: ${{ needs.check-addon-changes.outputs.changedAddons != '[]' }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| addon: ${{ fromJSON(needs.check-addon-changes.outputs.changedAddons) }} | |
| steps: | |
| - name: โฉ๏ธ Checkout | |
| uses: actions/checkout@v6 | |
| - name: ๐ Run Home Assistant Add-on Lint | |
| uses: frenck/action-addon-linter@v2 | |
| with: | |
| path: "./${{ matrix.addon }}" | |
| check-build: | |
| name: Test addon build | |
| needs: check-addon-changes | |
| if: ${{ needs.check-addon-changes.outputs.changedAddons != '[]' }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| addon: ${{ fromJSON(needs.check-addon-changes.outputs.changedAddons) }} | |
| steps: | |
| - name: โฉ๏ธ Checkout | |
| uses: actions/checkout@v6 | |
| - name: โน๏ธ Gather addon info | |
| id: information | |
| uses: frenck/action-addon-information@v1.4 | |
| with: | |
| path: "./${{ matrix.addon }}/" | |
| - name: ๐๏ธ Cache docker layers | |
| uses: actions/cache@v5 | |
| with: | |
| path: /tmp/buildx-cache | |
| key: ${{ runner.os }}-buildx-${{ matrix.addon }}-${{ hashFiles('**/Dockerfile') }} | |
| restore-keys: | | |
| ${{ runner.os }}-buildx-${{ matrix.addon }}- | |
| - name: ๐ Create addon image tags | |
| id: tags | |
| shell: bash | |
| run: | | |
| imagetemplate="${{ steps.information.outputs.image }}" | |
| version="${{ steps.information.outputs.version }}" | |
| echo "Using imagetemplate '${imagetemplate}'" | |
| { | |
| echo "armhf=${imagetemplate/\{arch\}/armhf}:${version}" | |
| echo "armv7=${imagetemplate/\{arch\}/armv7}:${version}" | |
| echo "aarch64=${imagetemplate/\{arch\}/aarch64}:${version}" | |
| echo "amd64=${imagetemplate/\{arch\}/amd64}:${version}" | |
| echo "i386=${imagetemplate/\{arch\}/i386}:${version}" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: ๐ท๏ธ Create addon labels | |
| id: labels | |
| shell: bash | |
| run: | | |
| labels="io.hass.version=${{ steps.information.outputs.version }}" | |
| labels=$(printf '%s' "$labels\nio.hass.name=${{ steps.information.outputs.name }}") | |
| labels=$(printf '%s' "$labels\nio.hass.description=${{ steps.information.outputs.description }}") | |
| labels=$(printf '%s' "$labels\nio.hass.type=addon") | |
| labels=$(printf '%s' "$labels\nio.hass.url=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/tree/master/${{ matrix.addon }}") | |
| labels=$(printf '%s' "$labels\norg.opencontainers.image.title=${{ steps.information.outputs.name }}") | |
| labels=$(printf '%s' "$labels\norg.opencontainers.image.description=${{ steps.information.outputs.description }}") | |
| labels=$(printf '%s' "$labels\norg.opencontainers.image.version=${{ steps.information.outputs.version }}") | |
| labels=$(printf '%s' "$labels\norg.opencontainers.image.authors=Poeschl <Poeschl@users.noreply.github.com>") | |
| labels=$(printf '%s' "$labels\norg.opencontainers.image.url=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}") | |
| labels=$(printf '%s' "$labels\norg.opencontainers.image.source=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/tree/master/${{ matrix.addon }}") | |
| labels=$(printf '%s' "$labels\norg.opencontainers.image.created=$(date -Is)") | |
| labels=$(printf '%s' "$labels\norg.opencontainers.image.revision=${GITHUB_SHA}") | |
| echo "Generic labels: $labels" | |
| armhf_labels=$(printf '%s' "$labels\nio.hass.arch=armhf") | |
| armv7_labels=$(printf '%s' "$labels\nio.hass.arch=armv7") | |
| aarch64_labels=$(printf '%s' "$labels\nio.hass.arch=aarch64") | |
| amd64_labels=$(printf '%s' "$labels\nio.hass.arch=amd64") | |
| i386_labels=$(printf '%s' "$labels\nio.hass.arch=i386") | |
| armhf_labels="${armhf_labels//$'\n'/'%0A'}" | |
| armv7_labels="${armv7_labels//$'\n'/'%0A'}" | |
| aarch64_labels="${aarch64_labels//$'\n'/'%0A'}" | |
| amd64_labels="${amd64_labels//$'\n'/'%0A'}" | |
| i386_labels="${i386_labels//$'\n'/'%0A'}" | |
| { | |
| echo "armhf=$armhf_labels" | |
| echo "armv7=$armv7_labels" | |
| echo "aarch64=$aarch64_labels" | |
| echo "amd64=$amd64_labels" | |
| echo "i386=$i386_labels" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: ๐ฝ Create addon build-args | |
| id: build_args | |
| shell: bash | |
| run: | | |
| { | |
| echo "armhf=BUILD_FROM=$(jq -r .build_from.armhf // empty ${{ steps.information.outputs.build }})" | |
| echo "armv7=BUILD_FROM=$(jq -r .build_from.armv7 // empty ${{ steps.information.outputs.build }})" | |
| echo "aarch64=BUILD_FROM=$(jq -r .build_from.aarch64 // empty ${{ steps.information.outputs.build }})" | |
| echo "amd64=BUILD_FROM=$(jq -r .build_from.amd64 // empty ${{ steps.information.outputs.build }})" | |
| echo "i386=BUILD_FROM=$(jq -r .build_from.i386 // empty ${{ steps.information.outputs.build }})" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: ๐๏ธ Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: ๐๏ธ Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: ๐ฟ Build Addon - armhf | |
| if: ${{ steps.information.outputs.armhf == 'true' }} | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ${{ matrix.addon }} | |
| push: false | |
| load: true | |
| file: ${{ matrix.addon }}/Dockerfile | |
| tags: ${{ steps.tags.outputs.armhf }} | |
| labels: ${{ steps.labels.outputs.armhf }} | |
| build-args: ${{ steps.build_args.outputs.armhf }} | |
| cache-from: type=local,src=/tmp/buildx-cache/armhf | |
| cache-to: type=local,dest=/tmp/buildx-cache-new/armhf | |
| - name: ๐ฟ Build Addon - armv7 | |
| if: ${{ steps.information.outputs.armv7 == 'true' }} | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ${{ matrix.addon }} | |
| push: false | |
| load: true | |
| file: ${{ matrix.addon }}/Dockerfile | |
| tags: ${{ steps.tags.outputs.armv7 }} | |
| labels: ${{ steps.labels.outputs.armv7 }} | |
| build-args: ${{ steps.build_args.outputs.armv7 }} | |
| cache-from: type=local,src=/tmp/buildx-cache/armv7 | |
| cache-to: type=local,dest=/tmp/buildx-cache-new/armv7 | |
| - name: ๐ฟ Build Addon - aarch64 | |
| if: ${{ steps.information.outputs.aarch64 == 'true' }} | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ${{ matrix.addon }} | |
| push: false | |
| load: true | |
| file: ${{ matrix.addon }}/Dockerfile | |
| tags: ${{ steps.tags.outputs.aarch64 }} | |
| labels: ${{ steps.labels.outputs.aarch64 }} | |
| build-args: ${{ steps.build_args.outputs.aarch64 }} | |
| cache-from: type=local,src=/tmp/buildx-cache/aarch64 | |
| cache-to: type=local,dest=/tmp/buildx-cache-new/aarch64 | |
| - name: ๐ฟ Build Addon - amd64 | |
| if: ${{ steps.information.outputs.amd64 == 'true' }} | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ${{ matrix.addon }} | |
| push: false | |
| load: true | |
| file: ${{ matrix.addon }}/Dockerfile | |
| tags: ${{ steps.tags.outputs.amd64 }} | |
| labels: ${{ steps.labels.outputs.amd64 }} | |
| build-args: ${{ steps.build_args.outputs.amd64 }} | |
| cache-from: type=local,src=/tmp/buildx-cache/amd64 | |
| cache-to: type=local,dest=/tmp/buildx-cache-new/amd64 | |
| - name: ๐ฟ Build Addon - i386 | |
| if: ${{ steps.information.outputs.i386 == 'true' }} | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ${{ matrix.addon }} | |
| push: false | |
| load: true | |
| file: ${{ matrix.addon }}/Dockerfile | |
| tags: ${{ steps.tags.outputs.i386 }} | |
| labels: ${{ steps.labels.outputs.i386 }} | |
| build-args: ${{ steps.build_args.outputs.i386 }} | |
| cache-from: type=local,src=/tmp/buildx-cache/i386 | |
| cache-to: type=local,dest=/tmp/buildx-cache-new/i386 | |
| - name: ๐๏ธ Update cache Folder | |
| run: | | |
| rm -rf /tmp/buildx-cache | |
| mv /tmp/buildx-cache-new /tmp/buildx-cache |