From 8b111e9eeda1f93c75921b5176a52b53151cc2fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Sun, 26 Sep 2021 18:28:49 +0200 Subject: [PATCH] Add more boilerplate (#10) --- .github/workflows/builder.yaml | 2 +- example/CHANGELOG.md | 9 ++++++++- example/Dockerfile | 8 +++++++- example/build.yaml | 7 +++++++ example/config.yaml | 6 +++++- example/rootfs/etc/services.d/example/run | 12 ++++++++++-- example/translations/en.yaml | 4 ++++ 7 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 example/translations/en.yaml diff --git a/.github/workflows/builder.yaml b/.github/workflows/builder.yaml index 87539a8..c93dd5a 100644 --- a/.github/workflows/builder.yaml +++ b/.github/workflows/builder.yaml @@ -81,7 +81,7 @@ jobs: run: | if [[ "${{ steps.info.outputs.architectures }}" =~ ${{ matrix.arch }} ]]; then echo "::set-output name=build_arch::true"; - echo "::set-output name=image::$(echo '${{ steps.info.outputs.image }}' | cut -d'/' -f3)"; + echo "::set-output name=image::$(echo ${{ steps.info.outputs.image }} | cut -d'/' -f3)"; if [[ -z "${{ github.head_ref }}" ]] && [[ "${{ github.event_name }}" == "push" ]]; then echo "BUILD_ARGS=" >> $GITHUB_ENV; fi diff --git a/example/CHANGELOG.md b/example/CHANGELOG.md index 21067b4..b8af34c 100644 --- a/example/CHANGELOG.md +++ b/example/CHANGELOG.md @@ -1,4 +1,11 @@ + +## 1.1.0 + +- Add configuration options +- Add labels to the docker image +- Install tempio in the docker image to show how args can be used + ## 1.0.1 - Use yaml for config and build files @@ -9,4 +16,4 @@ ## 0.1.0 -- Initial release \ No newline at end of file +- Initial release diff --git a/example/Dockerfile b/example/Dockerfile index 2e2b37c..97e560e 100644 --- a/example/Dockerfile +++ b/example/Dockerfile @@ -2,5 +2,11 @@ ARG BUILD_FROM FROM $BUILD_FROM +# Execute during the build of the image +ARG TEMPIO_VERSION BUILD_ARCH +RUN \ + curl -sSLf -o /usr/bin/tempio \ + "https://github.com/home-assistant/tempio/releases/download/${TEMPIO_VERSION}/tempio_${BUILD_ARCH}" + # Copy data -COPY rootfs / \ No newline at end of file +COPY rootfs / diff --git a/example/build.yaml b/example/build.yaml index 0debb53..f55c3e5 100644 --- a/example/build.yaml +++ b/example/build.yaml @@ -5,3 +5,10 @@ build_from: 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" +labels: + org.opencontainers.image.title: "Home Assistant Add-on: Example add-on" + org.opencontainers.image.description: "Example add-on to use as a blueprint for new add-ons." + org.opencontainers.image.source: "https://github.com/home-assistant/addons-example" + org.opencontainers.image.licenses: "Apache License 2.0" +args: + TEMPIO_VERSION: "2021.05.0" diff --git a/example/config.yaml b/example/config.yaml index 26da596..fad2e6d 100644 --- a/example/config.yaml +++ b/example/config.yaml @@ -1,6 +1,6 @@ # https://developers.home-assistant.io/docs/add-ons/configuration#add-on-config name: Example add-on -version: "1.0.1" +version: "1.1.0" slug: example description: Example add-on url: "https://github.com/home-assistant/addons-example/tree/master/example" @@ -11,4 +11,8 @@ arch: - amd64 - i386 startup: once +options: + message: "Hello world..." +schema: + message: "str?" image: "ghcr.io/home-assistant/{arch}-addon-example" diff --git a/example/rootfs/etc/services.d/example/run b/example/rootfs/etc/services.d/example/run index 76fa356..b58c3e1 100644 --- a/example/rootfs/etc/services.d/example/run +++ b/example/rootfs/etc/services.d/example/run @@ -3,8 +3,16 @@ # Start the example service # ============================================================================== -## Add your code here +# Add your code here -bashio::log.info "Hello world" +## Get the 'message' key from the user config options. +CONFIG_MESSAGE=$(bashio::config 'message') +## Set the message to be printed, defaults to "Hello World..." +PRINT_MESSAGE=${CONFIG_MESSAGE:="Hello World..."} + +## Print the message the user supplied +bashio::log.info "${PRINT_MESSAGE}" + +## Run your program # exec my_program --with-params diff --git a/example/translations/en.yaml b/example/translations/en.yaml new file mode 100644 index 0000000..70de024 --- /dev/null +++ b/example/translations/en.yaml @@ -0,0 +1,4 @@ +configuration: + message: + name: Message + description: The message that will be printed to the log when starting this example add-on.