diff --git a/.github/workflows/addon-ci.yml b/.github/workflows/addon-ci.yml index 60ce9a5..33dd5d0 100644 --- a/.github/workflows/addon-ci.yml +++ b/.github/workflows/addon-ci.yml @@ -11,6 +11,139 @@ on: - synchronize workflow_dispatch: +permissions: + actions: read + contents: read + packages: read + security-events: read + jobs: - workflows: - uses: hassio-addons/workflows/.github/workflows/addon-ci.yaml@main + information: + name: Gather app information + runs-on: ubuntu-latest + outputs: + architectures: ${{ steps.information.outputs.architectures }} + build: ${{ steps.information.outputs.build }} + description: ${{ steps.information.outputs.description }} + name: ${{ steps.information.outputs.name }} + slug: ${{ steps.information.outputs.slug }} + target: ${{ steps.information.outputs.target }} + steps: + - name: Check out code from GitHub + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + - name: Run app information action + id: information + uses: frenck/action-addon-information@ce1377e9851cf569c29329e65fb2c57e67ca0f69 # v1.4.2 + + lint-app: + name: Lint App + needs: + - information + runs-on: ubuntu-latest + steps: + - name: Check out code from GitHub + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + - name: Run App Lint + uses: frenck/action-addon-linter@f995494fd84fae6310d23617e66d0e37de4f14eb # v2.21.0 + with: + path: "./${{ needs.information.outputs.target }}" + + lint-hadolint: + name: Hadolint + needs: + - information + runs-on: ubuntu-latest + steps: + - name: Check out code from GitHub + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + - name: Run Hadolint + uses: brpaz/hadolint-action@v1.5.0 + with: + dockerfile: "./${{ needs.information.outputs.target }}/Dockerfile" + + lint-json: + name: JSON Lint + runs-on: ubuntu-latest + steps: + - name: Check out code from GitHub + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + - name: Run JQ + run: | + shopt -s globstar nullglob + for file in **/*.json; do + if ! jq '.' "$file" > /dev/null 2>&1; then + echo "::error file=${file}::Invalid JSON in ${file}" + jq '.' "$file" + exit 1 + fi + done + + lint-shellcheck: + name: Shellcheck + runs-on: ubuntu-latest + steps: + - name: Check out code from GitHub + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + - name: Run Shellcheck + uses: ludeeus/action-shellcheck@2.0.0 + env: + SHELLCHECK_OPTS: -s bash + + lint-yamllint: + name: YAMLLint + runs-on: ubuntu-latest + steps: + - name: Check out code from GitHub + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + - name: Run YAMLLint + uses: frenck/action-yamllint@34b4bbcaeabedcfefad6adea8c5bbc42af0e2d47 # v1.5 + + lint-prettier: + name: Prettier + runs-on: ubuntu-latest + steps: + - name: Check out code from GitHub + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + - name: Run Prettier + uses: creyD/prettier_action@v4.6 + with: + prettier_options: --check **/*.{json,js,md,yaml} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + lint-zizmor: + name: zizmor + runs-on: ubuntu-latest + steps: + - name: Check out code from GitHub + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + - name: Run zizmor + uses: zizmorcore/zizmor-action@5f14fd08f7cf1cb1609c1e344975f152c7ee938d # v0.5.6 + + dependency-review: + name: Dependency review + if: github.event_name == 'pull_request' + runs-on: ubuntu-latest + steps: + - name: Check out code from GitHub + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + - name: Dependency review + uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5.0.0 diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml deleted file mode 100644 index 6c5b822..0000000 --- a/.github/workflows/build.yaml +++ /dev/null @@ -1,114 +0,0 @@ ---- -name: Builder - -env: - BUILD_ARGS: "--test" - MONITORED_FILES: "build.yaml config.yaml Dockerfile rootfs" - -# yamllint disable-line rule:truthy -on: - push: - branches: - - build - pull_request: - branches: - - build - -jobs: - init: - runs-on: ubuntu-latest - name: Initialize builds - outputs: - changed_addons: ${{ steps.changed_addons.outputs.addons }} - changed: ${{ steps.changed_addons.outputs.changed }} - steps: - - name: Check out the repository - uses: actions/checkout@v3.6.0 - - - name: Get changed files - id: changed_files - uses: jitterbit/get-changed-files@v1 - - - name: Find add-on directories - id: addons - uses: home-assistant/actions/helpers/find-addons@master - - - name: Get changed add-ons - id: changed_addons - run: | - declare -a changed_addons - for addon in ${{ steps.addons.outputs.addons }}; do - if [[ "${{ steps.changed_files.outputs.all }}" =~ $addon ]]; then - for file in ${{ env.MONITORED_FILES }}; do - if [[ "${{ steps.changed_files.outputs.all }}" =~ $addon/$file ]]; then - if [[ ! "${changed_addons[@]}" =~ $addon ]]; then - changed_addons+=("\"${addon}\","); - fi - fi - done - fi - done - - changed=$(echo ${changed_addons[@]} | rev | cut -c 2- | rev) - - if [[ -n ${changed} ]]; then - echo "Changed add-ons: $changed"; - echo "changed=true" >> $GITHUB_OUTPUT; - echo "addons=[$changed]" >> $GITHUB_OUTPUT; - else - echo "No add-on had any monitored files changed (${{ env.MONITORED_FILES }})"; - fi - build: - needs: init - runs-on: ubuntu-latest - if: needs.init.outputs.changed == 'true' - name: Build ${{ matrix.arch }} ${{ matrix.addon }} add-on - strategy: - matrix: - addon: ${{ fromJson(needs.init.outputs.changed_addons) }} - # arch: ["aarch64", "amd64", "armhf", "armv7", "i386"] - arch: ["aarch64", "amd64", "armv7"] - - steps: - - name: Check out repository - uses: actions/checkout@v3.6.0 - - - name: Get information - id: info - uses: home-assistant/actions/helpers/info@master - with: - path: "./${{ matrix.addon }}" - - - name: Check if add-on should be built - id: check - run: | - if [[ "${{ steps.info.outputs.architectures }}" =~ ${{ matrix.arch }} ]]; then - echo "build_arch=true" >> $GITHUB_OUTPUT; - echo "image=$(echo ${{ steps.info.outputs.image }} | cut -d'/' -f3)" >> $GITHUB_OUTPUT; - 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 "build_arch=false" >> $GITHUB_OUTPUT; - fi - - - name: Login to GitHub Container Registry - if: env.BUILD_ARGS != '--test' - uses: docker/login-action@v2.2.0 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build ${{ matrix.addon }} add-on - if: steps.check.outputs.build_arch == 'true' - uses: home-assistant/builder@2023.08.0 - with: - args: | - ${{ env.BUILD_ARGS }} \ - --${{ matrix.arch }} \ - --target /data/${{ matrix.addon }} \ - --image "${{ steps.check.outputs.image }}" \ - --docker-hub "ghcr.io/${{ github.repository_owner }}" \ - --addon diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 29d5d25..4eaf8f9 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -6,15 +6,111 @@ on: release: types: - published - workflow_run: - workflows: ["CI"] - branches: [meters-to-ha] - types: - - completed + workflow_dispatch: + +permissions: + contents: read + id-token: write + packages: write jobs: - workflows: - uses: hassio-addons/workflows/.github/workflows/addon-deploy.yaml@main - #secrets: inherit - secrets: - DISPATCH_TOKEN: ${{ secrets.DISPATCH_TOKEN }} + prepare: + name: Prepare + runs-on: ubuntu-latest + outputs: + architectures: ${{ steps.info.outputs.architectures }} + build_matrix: ${{ steps.matrix.outputs.matrix }} + image_name: ${{ steps.normalize.outputs.image_name }} + name: ${{ steps.normalize.outputs.name }} + description: ${{ steps.normalize.outputs.description }} + url: ${{ steps.normalize.outputs.url }} + registry_prefix: ${{ steps.normalize.outputs.registry_prefix }} + version: ${{ steps.normalize.outputs.version }} + steps: + - name: Check out the repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2 + + - name: Get app information + id: info + uses: home-assistant/actions/helpers/info@master + with: + path: "./addon_meterstoha" + + - name: Normalize app information + id: normalize + run: | + image=${{ steps.info.outputs.image }} + echo "image_name=${image##*/}" >> "$GITHUB_OUTPUT" + echo "registry_prefix=${image%/*}" >> "$GITHUB_OUTPUT" + version=${{ steps.info.outputs.version }} + echo "version=${version}" >> "$GITHUB_OUTPUT" + name=${{ steps.info.outputs.name }} + echo "name=${name}" >> "$GITHUB_OUTPUT" + description=${{ steps.info.outputs.description }} + echo "description=${description}" >> "$GITHUB_OUTPUT" + url=${{ steps.info.outputs.url }} + if [[ -n "$url" && "$url" != "null" ]]; then + echo "url=${url}" >> "$GITHUB_OUTPUT" + fi + + - name: Prepare build matrix + id: matrix + uses: home-assistant/builder/actions/prepare-multi-arch-matrix@2026.03.2 + with: + architectures: ${{ steps.info.outputs.architectures }} + image-name: ${{ steps.normalize.outputs.image_name }} + registry-prefix: ${{ steps.normalize.outputs.registry_prefix }} + + build: + name: Build ${{ matrix.arch }} image + needs: prepare + runs-on: ${{ matrix.os }} + permissions: + contents: read + id-token: write + packages: write + strategy: + fail-fast: false + matrix: ${{ fromJSON(needs.prepare.outputs.build_matrix) }} + steps: + - name: Check out the repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2 + with: + persist-credentials: false + + - name: Build image + uses: home-assistant/builder/actions/build-image@2026.03.2 + with: + arch: ${{ matrix.arch }} + container-registry-password: ${{ secrets.GITHUB_TOKEN }} + context: "./addon_meterstoha" + image: ${{ matrix.image }} + image-tags: | + ${{ needs.prepare.outputs.version }} + latest + labels: | + io.hass.type=app + io.hass.name=${{ needs.prepare.outputs.name }} + io.hass.description=${{ needs.prepare.outputs.description }} + ${{ needs.prepare.outputs.url && format('io.hass.url={0}', needs.prepare.outputs.url) || '' }} + push: true + version: ${{ needs.prepare.outputs.version }} + + manifest: + name: Publish multi-arch manifest + needs: [prepare, build] + runs-on: ubuntu-latest + permissions: + id-token: write + packages: write + steps: + - name: Publish multi-arch manifest + uses: home-assistant/builder/actions/publish-multi-arch-manifest@8b139affa26d40fa3cc0d0cb77a8aefaf417a460 + with: + architectures: ${{ needs.prepare.outputs.architectures }} + container-registry-password: ${{ secrets.GITHUB_TOKEN }} + image-name: ${{ needs.prepare.outputs.image_name }} + image-tags: | + ${{ needs.prepare.outputs.version }} + latest + registry-prefix: ${{ needs.prepare.outputs.registry_prefix }} diff --git a/.github/workflows/docker-image_new.yml b/.github/workflows/docker-image_new.yml deleted file mode 100644 index 2c27737..0000000 --- a/.github/workflows/docker-image_new.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -name: Docker Image CI -# yamllint disable-line rule:truthy -on: - push: - branches: [meters-to-ha] - pull_request: - branches: [meters-to-ha] -env: - DOCKER_HUB_NAME: ${{ secrets.DOCKER_HUB_NAME || github.repository }} - DOCKERFILE: ./DockerfileAlpine -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v5 - - name: Build the Docker image - run: docker build . --file ${{ env.DOCKERFILE }} --tag my-image-name:$(date +%s) - - name: Login to DockerHub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - - # Production versions - - name: Build and push - uses: docker/build-push-action@v5 - with: - context: . - file: ${{ env.DOCKERFILE }} - push: true - tags: ${{ env.DOCKER_HUB_NAME }}:latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cffe557..8c12464 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,7 +27,7 @@ jobs: cd apps/meters_to_ha zip MetersToHA.zip -r ./ - name: Upload zip to release - uses: svenstaro/upload-release-action@v1-release + uses: svenstaro/upload-release-action@2.11.5 with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: ./apps/meters_to_ha/MetersToHA.zip diff --git a/Dockerfile b/Dockerfile index 27c1718..22bc31d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,19 @@ ## Start from the official Ubuntu image FROM ubuntu:24.04 +# hadolint ignore=DL3006 LABEL maintainer="MDW " ## Set environment variables ENV LANG=C.UTF-8 LC_ALL=C.UTF-8 -# Not on 22.04: firefox-geckodriver, need ppa - +# Not on 22.04: firefox-geckodriver, need ppa # Next lines would upgrade image - skipping # && apt-get upgrade -y \ # && apt-get dist-upgrade -y \ +# hadolint ignore=DL3003 RUN export DEBIAN_FRONTEND="noninteractive" \ && echo 'APT::Keep-Downloaded-Packages "false";' \ > /etc/apt/apt.conf.d/01disable-cache \ @@ -42,9 +43,11 @@ RUN export DEBIAN_FRONTEND="noninteractive" \ && apt clean && apt autoremove -y \ && rm -rf /var/lib/apt/lists/* -RUN addgroup -gid 1000 docker && adduser -disabled-password -u 1000 -gid 1000 docker +# hadolint ignore=DL3003 +RUN addgroup -gid 1000 docker && adduser -disabled-password -u 1000 -gid 1000 docker # Install packages to Python3 +# hadolint ignore=DL3003 # RUN pip3 install --upgrade pip \ # && pip3 install \ # "urllib3>=1.24.2" \ diff --git a/addon_meterstoha/build.yaml b/addon_meterstoha/build.yaml index e3cc2a4..ead782e 100644 --- a/addon_meterstoha/build.yaml +++ b/addon_meterstoha/build.yaml @@ -3,7 +3,7 @@ build_from: aarch64: ghcr.io/hassio-addons/base:20.1.1 amd64: ghcr.io/hassio-addons/base:20.1.1 # armhf: ghcr.io/hassio-addons/base:20.1.1 - armv7: ghcr.io/hassio-addons/base:20.1.1 + # armv7 is deprecated and no longer supported as of Home Assistant 2025.12 # i386: ghcr.io/hassio-addons/base:20.1.1 # codenotary: # base_image: dummy@dummy.com diff --git a/addon_meterstoha/config.yaml b/addon_meterstoha/config.yaml index 7611f96..d6b08e6 100644 --- a/addon_meterstoha/config.yaml +++ b/addon_meterstoha/config.yaml @@ -1,8 +1,8 @@ --- name: MetersToHA -version: "v2026.5.3" +version: "2026.5.3" slug: meterstoha -description: MetersToHA add-on for Home Assistant +description: MetersToHA app for Home Assistant url: https://github.com/mdeweerd/meterstoha homeassistant_api: true map: @@ -13,11 +13,12 @@ host_dbus: true arch: - aarch64 - amd64 - - armv7 + # armv7 is deprecated and no longer supported as of Home Assistant 2025.12 # Next architectures are missing the chromium-browser # Need to check for firefox availability # - armhf # - i386 +image: "ghcr.io/mdeweerd/meterstoha" options: log_level: info timeout: "30" @@ -70,4 +71,4 @@ schema: domoticz_server: url? domoticz_idx: str? git_version: str? -# image: ghcr.io/mdeweerd/meterstoha/addon_meterstoha/{arch} +# image: ghcr.io/mdeweerd/meterstoha/{arch} diff --git a/repository.yaml b/repository.yaml new file mode 100644 index 0000000..35a6b73 --- /dev/null +++ b/repository.yaml @@ -0,0 +1,5 @@ +--- +# https://developers.home-assistant.io/docs/apps/repository#repository-configuration +name: MetersToHA +url: "https://github.com/mdeweerd/meterstoha" +maintainer: MDW