Use yaml files (#9)

This commit is contained in:
Joakim Sørensen
2021-09-26 17:05:37 +02:00
committed by GitHub
parent 0bbf0dd6cd
commit f7242ec678
8 changed files with 42 additions and 58 deletions

View File

@@ -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";
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
else
echo "${{ matrix.arch }} is not a valid arch for ${{ matrix.addon }}, skipping build";
echo "::set-output name=build_arch::false";
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

View File

@@ -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 }}

View File

@@ -25,16 +25,16 @@ _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
- While developing comment out the 'image' key from 'example/config.yaml' 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 adjust the 'version' key in 'example/config.yaml' 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'.
- Adjust the 'image' key in 'example/config.yaml' 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.
- The 'slug' key in 'example/config.yaml' 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!

View File

@@ -1,4 +1,8 @@
<!-- https://developers.home-assistant.io/docs/add-ons/presentation#keeping-a-changelog -->
## 1.0.1
- Use yaml for config and build files
## 1.0.0
- Complete refresh of all files

View File

@@ -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"
}
}

7
example/build.yaml Normal file
View File

@@ -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"

View File

@@ -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"
}

14
example/config.yaml Normal file
View File

@@ -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"