Complete refresh (#7)
This commit is contained in:
7
.github/dependabot.yaml
vendored
Normal file
7
.github/dependabot.yaml
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: daily
|
||||
time: "06:00"
|
||||
118
.github/workflows/builder.yaml
vendored
Normal file
118
.github/workflows/builder.yaml
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
name: Builder
|
||||
|
||||
env:
|
||||
BUILD_ARGS: "--test"
|
||||
MONITORED_FILES: "build.json config.json Dockerfile rootfs"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
init:
|
||||
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:
|
||||
- name: Check out the repository
|
||||
uses: actions/checkout@v2.3.4
|
||||
|
||||
- name: Get changed files
|
||||
id: changed_files
|
||||
uses: jitterbit/get-changed-files@v1
|
||||
|
||||
- name: Get add-ons
|
||||
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[@]}"
|
||||
- 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 "::set-output name=changed::true";
|
||||
echo "::set-output name=addons::[$changed]";
|
||||
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"]
|
||||
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@v2.3.4
|
||||
|
||||
- name: Get information
|
||||
id: info
|
||||
uses: home-assistant/actions/helpers/info@master
|
||||
with:
|
||||
path: "./${{ matrix.addon }}"
|
||||
|
||||
- name: Check add-on
|
||||
id: check
|
||||
run: |
|
||||
if [[ "${{ steps.info.outputs.architectures }}" =~ ${{ matrix.arch }} ]]; then
|
||||
echo "::set-output name=build_arch::true";
|
||||
else
|
||||
echo "${{ matrix.arch }} is not a valid arch for ${{ matrix.addon }}, skipping build";
|
||||
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'
|
||||
uses: docker/login-action@v1.10.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@2021.07.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
|
||||
49
.github/workflows/lint.yaml
vendored
Normal file
49
.github/workflows/lint.yaml
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
name: Lint
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
schedule:
|
||||
- cron: "0 0 * * *"
|
||||
|
||||
jobs:
|
||||
find:
|
||||
name: Find add-ons
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
addons: ${{ steps.addons.outputs.addons }}
|
||||
steps:
|
||||
- name: ⤵️ Check out code from GitHub
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- 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}]"
|
||||
|
||||
|
||||
lint:
|
||||
name: Lint add-on ${{ matrix.path }}
|
||||
runs-on: ubuntu-latest
|
||||
needs: find
|
||||
strategy:
|
||||
matrix:
|
||||
path: ${{ fromJson(needs.find.outputs.addons) }}
|
||||
steps:
|
||||
- name: ⤵️ Check out code from GitHub
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: 🚀 Run Home Assistant Add-on Lint
|
||||
uses: frenck/action-addon-linter@v2.3.0
|
||||
with:
|
||||
path: "./${{ matrix.path }}"
|
||||
50
README.md
Normal file
50
README.md
Normal file
@@ -0,0 +1,50 @@
|
||||
# Example Home Assistant add-on repository
|
||||
|
||||
This repository can be used as a "blueprint" for add-on development to help you get started.
|
||||
|
||||
Add-on documentation: <https://developers.home-assistant.io/docs/add-ons>
|
||||
|
||||
|
||||
[](https://my.home-assistant.io/redirect/supervisor_add_addon_repository/?repository_url=https%3A%2F%2Fgithub.com%2Fhome-assistant%2Faddons-example)
|
||||
|
||||
## Add-ons
|
||||
|
||||
This repository contains the following add-ons
|
||||
|
||||
### [Example add-on](./example)
|
||||
|
||||
![Supports aarch64 Architecture][aarch64-shield]
|
||||
![Supports amd64 Architecture][amd64-shield]
|
||||
![Supports armhf Architecture][armhf-shield]
|
||||
![Supports armv7 Architecture][armv7-shield]
|
||||
![Supports i386 Architecture][i386-shield]
|
||||
|
||||
_Example add-on to use as a blueprint for new add-ons._
|
||||
|
||||
|
||||
<!--
|
||||
|
||||
Notes to developers after forking or using the github template feature:
|
||||
- While developing remove the 'image' tag from 'example/config.json' to make the supervisor build the addon
|
||||
- Remember to put this back when pushing up your changes.
|
||||
- When you merge to the 'master' branch of your repository a new build will be triggered.
|
||||
- Make sure you adjust the 'version' key in 'example/config.json' when you do that.
|
||||
- Make sure you update 'example/CHANGELOG.md' when you do that.
|
||||
- The first time this runs you might need to adjust the image configuration on github container registry to make it public
|
||||
- Adjust the 'image' key in 'example/config.json' so it points to your username instead of 'home-assistant'.
|
||||
- This is where the build images will be published to.
|
||||
- Rename the example directory.
|
||||
- The 'slug' key in 'example/config.json' should match the directory name.
|
||||
- Adjust all keys/url's that points to 'home-assistant' to now point to your user/fork.
|
||||
- Share your repository on the forums https://community.home-assistant.io/c/projects/9
|
||||
- Do awesome stuff!
|
||||
-->
|
||||
|
||||
|
||||
|
||||
|
||||
[aarch64-shield]: https://img.shields.io/badge/aarch64-yes-green.svg
|
||||
[amd64-shield]: https://img.shields.io/badge/amd64-yes-green.svg
|
||||
[armhf-shield]: https://img.shields.io/badge/armhf-yes-green.svg
|
||||
[armv7-shield]: https://img.shields.io/badge/armv7-yes-green.svg
|
||||
[i386-shield]: https://img.shields.io/badge/i386-yes-green.svg
|
||||
@@ -1,14 +0,0 @@
|
||||
ARG BUILD_FROM
|
||||
FROM $BUILD_FROM
|
||||
|
||||
# Add env
|
||||
ENV LANG C.UTF-8
|
||||
|
||||
# Setup base
|
||||
RUN apk add --no-cache jq
|
||||
|
||||
# Copy data
|
||||
COPY run.sh /
|
||||
RUN chmod a+x /run.sh
|
||||
|
||||
CMD [ "/run.sh" ]
|
||||
@@ -1,19 +0,0 @@
|
||||
{
|
||||
"name": "Coffee Maker",
|
||||
"version": "1.2",
|
||||
"slug": "coffee_maker",
|
||||
"arch": ["armhf", "armv7", "aarch64", "amd64", "i386"],
|
||||
"description": "Expose a web frontend to control my coffee maker",
|
||||
"startup": "before",
|
||||
"boot": "auto",
|
||||
"ports": {
|
||||
"80/tcp": 8080
|
||||
},
|
||||
"options": {
|
||||
"device": null
|
||||
},
|
||||
"schema": {
|
||||
"device": "str"
|
||||
},
|
||||
"image": "hub/{arch}-coffee-maker"
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
#!/bin/bash
|
||||
sed -e
|
||||
|
||||
CONFIG_PATH=/data/options.json
|
||||
|
||||
DEVICE=$(jq --raw-output ".device" $CONFIG_PATH)
|
||||
|
||||
echo "We can now make coffee on device: $DEVICE"
|
||||
8
example/CHANGELOG.md
Normal file
8
example/CHANGELOG.md
Normal file
@@ -0,0 +1,8 @@
|
||||
<!-- https://developers.home-assistant.io/docs/add-ons/presentation#keeping-a-changelog -->
|
||||
## 1.0.0
|
||||
|
||||
- Complete refresh of all files
|
||||
|
||||
## 0.1.0
|
||||
|
||||
- Initial release
|
||||
15
example/DOCS.md
Normal file
15
example/DOCS.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# Home Assistant Add-on: Example add-on
|
||||
|
||||
## Installation
|
||||
|
||||
Follow these steps to get the add-on installed on your system:
|
||||
|
||||
1. Navigate in your Home Assistant frontend to **Supervisor** -> **Add-on Store**.
|
||||
1. Find the "Example add-on" add-on and click it.
|
||||
1. Click on the "INSTALL" button.
|
||||
|
||||
## How to use
|
||||
|
||||
This add-on really does nothing. It is just an example.
|
||||
|
||||
When started it will print "Hello world" in the log and exit.
|
||||
6
example/Dockerfile
Normal file
6
example/Dockerfile
Normal file
@@ -0,0 +1,6 @@
|
||||
# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-dockerfile
|
||||
ARG BUILD_FROM
|
||||
FROM $BUILD_FROM
|
||||
|
||||
# Copy data
|
||||
COPY rootfs /
|
||||
17
example/README.md
Normal file
17
example/README.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Home Assistant Add-on: Example add-on
|
||||
|
||||
_Example add-on to use as a blueprint for new add-ons._
|
||||
|
||||
![Supports aarch64 Architecture][aarch64-shield]
|
||||
![Supports amd64 Architecture][amd64-shield]
|
||||
![Supports armhf Architecture][armhf-shield]
|
||||
![Supports armv7 Architecture][armv7-shield]
|
||||
![Supports i386 Architecture][i386-shield]
|
||||
|
||||
|
||||
|
||||
[aarch64-shield]: https://img.shields.io/badge/aarch64-yes-green.svg
|
||||
[amd64-shield]: https://img.shields.io/badge/amd64-yes-green.svg
|
||||
[armhf-shield]: https://img.shields.io/badge/armhf-yes-green.svg
|
||||
[armv7-shield]: https://img.shields.io/badge/armv7-yes-green.svg
|
||||
[i386-shield]: https://img.shields.io/badge/i386-yes-green.svg
|
||||
9
example/build.json
Normal file
9
example/build.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
16
example/config.json
Normal file
16
example/config.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
BIN
example/icon.png
Normal file
BIN
example/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 47 KiB |
5
example/rootfs/etc/services.d/example/finish
Normal file
5
example/rootfs/etc/services.d/example/finish
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/execlineb -S1
|
||||
# ==============================================================================
|
||||
# Take down the S6 supervision tree when example fails
|
||||
# ==============================================================================
|
||||
s6-svscanctl -t /var/run/s6/services
|
||||
8
example/rootfs/etc/services.d/example/run
Normal file
8
example/rootfs/etc/services.d/example/run
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Start the example service
|
||||
# ==============================================================================
|
||||
|
||||
## Add your code here
|
||||
|
||||
bashio::log.info "Hello world"
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"name": "Hass.IO example add-on repository",
|
||||
"url": "https://home-assistant.io/",
|
||||
"maintainer": "HomeAssistant <info@home-assistant.io>"
|
||||
}
|
||||
4
repository.yaml
Normal file
4
repository.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
# https://developers.home-assistant.io/docs/add-ons/repository#repository-configuration
|
||||
name: Example Home Assistant add-on repository
|
||||
url: 'https://github.com/home-assistant/addons-example'
|
||||
maintainer: Awesome Maintainer <awesome@example.com>
|
||||
@@ -1,14 +0,0 @@
|
||||
ARG BUILD_FROM
|
||||
FROM $BUILD_FROM
|
||||
|
||||
# Add env
|
||||
ENV LANG C.UTF-8
|
||||
|
||||
# Setup base
|
||||
RUN apk add --no-cache jq
|
||||
|
||||
# Copy data
|
||||
COPY run.sh /
|
||||
RUN chmod a+x /run.sh
|
||||
|
||||
CMD [ "/run.sh" ]
|
||||
@@ -1,21 +0,0 @@
|
||||
{
|
||||
"name": "Sync",
|
||||
"version": "0.4",
|
||||
"slug": "sync",
|
||||
"arch": ["armhf", "armv7", "aarch64", "amd64", "i386"],
|
||||
"description": "Sync config files over sftp",
|
||||
"startup": "once",
|
||||
"boot": "manual",
|
||||
"map": ["config"],
|
||||
"options": {
|
||||
"target": null,
|
||||
"username": null,
|
||||
"password": ""
|
||||
},
|
||||
"schema": {
|
||||
"target": "url",
|
||||
"username": "str",
|
||||
"password": "str"
|
||||
},
|
||||
"image": "hub/{arch}-sync"
|
||||
}
|
||||
10
sync/run.sh
10
sync/run.sh
@@ -1,10 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
CONFIG_PATH=/data/options.json
|
||||
|
||||
TARGET=$(jq --raw-output ".target" $CONFIG_PATH)
|
||||
USERNAME=$(jq --raw-output ".username" $CONFIG_PATH)
|
||||
PASSWORD=$(jq --raw-output ".password" $CONFIG_PATH)
|
||||
|
||||
echo "fake copy from /config to $TARGET@$USERNAME"
|
||||
Reference in New Issue
Block a user