diff --git a/.github/workflows/builder.yaml b/.github/workflows/builder.yaml index b31eff7..ea6e81b 100644 --- a/.github/workflows/builder.yaml +++ b/.github/workflows/builder.yaml @@ -2,7 +2,7 @@ name: Builder env: BUILD_ARGS: "--test" - MONITORED_FILES: "build.json config.json Dockerfile rootfs" + MONITORED_FILES: "build.yaml config.yaml Dockerfile rootfs" on: push: @@ -17,7 +17,6 @@ jobs: runs-on: ubuntu-latest name: Initialize builds outputs: - changed_files: ${{ steps.changed_files.outputs.all }} changed_addons: ${{ steps.changed_addons.outputs.addons }} changed: ${{ steps.changed_addons.outputs.changed }} steps: @@ -28,14 +27,10 @@ jobs: id: changed_files uses: jitterbit/get-changed-files@v1 - - name: Get add-ons + - name: Find add-on directories id: addons - run: | - declare -a addons - for addon in $(find ./ -name config.json | cut -d "/" -f2 | sort -u); do - addons+=("$addon"); - done - echo "::set-output name=addons::${addons[@]}" + uses: home-assistant/actions/helpers/find-addons@master + - name: Get changed add-ons id: changed_addons run: | @@ -51,7 +46,9 @@ jobs: done fi done + changed=$(echo ${changed_addons[@]} | rev | cut -c 2- | rev) + if [[ -n ${changed} ]]; then echo "Changed add-ons: $changed"; echo "::set-output name=changed::true"; @@ -79,23 +76,18 @@ jobs: with: path: "./${{ matrix.addon }}" - - name: Check add-on + - name: Check if add-on should be built id: check run: | if [[ "${{ steps.info.outputs.architectures }}" =~ ${{ matrix.arch }} ]]; then echo "::set-output name=build_arch::true"; + if [[ -z "${{ github.head_ref }}" ]] && [[ "${{ github.event_name }}" == "push" ]]; then + echo "BUILD_ARGS=" >> $GITHUB_ENV; + fi else echo "${{ matrix.arch }} is not a valid arch for ${{ matrix.addon }}, skipping build"; + echo "::set-output name=build_arch::false"; fi - image=$(jq -r '.image' "./${{ matrix.addon }}/config.json" | cut -d"/" -f3) - echo "::set-output name=image::${image}"; - - - name: Set build arguments - if: steps.check.outputs.build_arch == 'true' - run: | - if [[ -z "${{ github.head_ref }}" ]] && [[ "${{ github.event_name }}" == "push" ]]; then - echo "BUILD_ARGS=" >> $GITHUB_ENV; - fi - name: Login to GitHub Container Registry if: env.BUILD_ARGS != '--test' @@ -113,6 +105,6 @@ jobs: ${{ env.BUILD_ARGS }} \ --${{ matrix.arch }} \ --target /data/${{ matrix.addon }} \ - --image "${{ steps.check.outputs.image }}" \ + --image "$(echo '${{ steps.info.outputs.image }}' | cut -d'/' -f3)" \ --docker-hub "ghcr.io/${{ github.repository_owner }}" \ --addon diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 2f92e09..2866162 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -22,15 +22,7 @@ jobs: - name: 🔍 Find add-on directories id: addons - run: | - declare -a found_addons - for addon in $(find ./ -name config.json | cut -d "/" -f2 | sort -u); do - found_addons+=("\"${addon}\","); - done - addons=$(echo ${found_addons[@]} | rev | cut -c 2- | rev) - echo "Add-ons found: ${addons}" - echo "::set-output name=addons::[${addons}]" - + uses: home-assistant/actions/helpers/find-addons@master lint: name: Lint add-on ${{ matrix.path }} diff --git a/README.md b/README.md index 6bd17a2..2025fbb 100644 --- a/README.md +++ b/README.md @@ -25,16 +25,16 @@ _Example add-on to use as a blueprint for new add-ons._ +## 1.0.1 + +- Use yaml for config and build files + ## 1.0.0 - Complete refresh of all files diff --git a/example/build.json b/example/build.json deleted file mode 100644 index 2f64ae1..0000000 --- a/example/build.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "build_from": { - "aarch64": "ghcr.io/home-assistant/aarch64-base:3.14", - "amd64": "ghcr.io/home-assistant/amd64-base:3.14", - "armhf": "ghcr.io/home-assistant/armhf-base:3.14", - "armv7": "ghcr.io/home-assistant/armv7-base:3.14", - "i386": "ghcr.io/home-assistant/i386-base:3.14" - } -} \ No newline at end of file diff --git a/example/build.yaml b/example/build.yaml new file mode 100644 index 0000000..0debb53 --- /dev/null +++ b/example/build.yaml @@ -0,0 +1,7 @@ +# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-dockerfile +build_from: + aarch64: "ghcr.io/home-assistant/aarch64-base:3.14" + amd64: "ghcr.io/home-assistant/amd64-base:3.14" + armhf: "ghcr.io/home-assistant/armhf-base:3.14" + armv7: "ghcr.io/home-assistant/armv7-base:3.14" + i386: "ghcr.io/home-assistant/i386-base:3.14" diff --git a/example/config.json b/example/config.json deleted file mode 100644 index 1f50e5e..0000000 --- a/example/config.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "Example add-on", - "version": "1.0.0", - "slug": "example", - "description": "Example add-on", - "url": "https://github.com/home-assistant/addons-example/tree/master/example", - "arch": [ - "armhf", - "armv7", - "aarch64", - "amd64", - "i386" - ], - "startup": "once", - "image": "ghcr.io/home-assistant/{arch}-addon-example" -} diff --git a/example/config.yaml b/example/config.yaml new file mode 100644 index 0000000..26da596 --- /dev/null +++ b/example/config.yaml @@ -0,0 +1,14 @@ +# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-config +name: Example add-on +version: "1.0.1" +slug: example +description: Example add-on +url: "https://github.com/home-assistant/addons-example/tree/master/example" +arch: + - armhf + - armv7 + - aarch64 + - amd64 + - i386 +startup: once +image: "ghcr.io/home-assistant/{arch}-addon-example"