Skip to content

Commit f7a08e8

Browse files
authored
Initial commit
0 parents  commit f7a08e8

File tree

21 files changed

+675
-0
lines changed

21 files changed

+675
-0
lines changed

.devcontainer.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "Example devcontainer for add-on repositories",
3+
"image": "ghcr.io/home-assistant/devcontainer:2-addons",
4+
"appPort": ["7123:8123", "7357:4357"],
5+
"postStartCommand": "bash devcontainer_bootstrap",
6+
"runArgs": ["-e", "GIT_EDITOR=code --wait", "--privileged"],
7+
"containerEnv": {
8+
"WORKSPACE_DIRECTORY": "${containerWorkspaceFolder}"
9+
},
10+
"workspaceFolder": "/mnt/supervisor/addons/local/${localWorkspaceFolderBasename}",
11+
"workspaceMount": "source=${localWorkspaceFolder},target=${containerWorkspaceFolder},type=bind,consistency=cached",
12+
"customizations": {
13+
"vscode": {
14+
"extensions": ["timonwong.shellcheck", "esbenp.prettier-vscode"],
15+
"settings": {
16+
"terminal.integrated.profiles.linux": {
17+
"zsh": {
18+
"path": "/usr/bin/zsh"
19+
}
20+
},
21+
"terminal.integrated.defaultProfile.linux": "zsh",
22+
"editor.formatOnPaste": false,
23+
"editor.formatOnSave": true,
24+
"editor.formatOnType": true,
25+
"files.trimTrailingWhitespace": true
26+
}
27+
}
28+
},
29+
"mounts": [
30+
"type=volume,target=/var/lib/docker",
31+
"type=volume,target=/mnt/supervisor"
32+
]
33+
}

.github/dependabot.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: weekly
7+
time: "06:00"

.github/workflows/builder.yaml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Builder
2+
3+
env:
4+
BUILD_ARGS: "--test"
5+
MONITORED_FILES: "build.yaml config.yaml Dockerfile rootfs"
6+
7+
on:
8+
push:
9+
branches:
10+
- main
11+
pull_request:
12+
branches:
13+
- main
14+
15+
jobs:
16+
init:
17+
runs-on: ubuntu-latest
18+
name: Initialize builds
19+
outputs:
20+
changed_addons: ${{ steps.changed_addons.outputs.addons }}
21+
changed: ${{ steps.changed_addons.outputs.changed }}
22+
steps:
23+
- name: Check out the repository
24+
uses: actions/checkout@v6.0.1
25+
26+
- name: Get changed files
27+
id: changed_files
28+
uses: jitterbit/get-changed-files@v1
29+
30+
- name: Find add-on directories
31+
id: addons
32+
uses: home-assistant/actions/helpers/find-addons@master
33+
34+
- name: Get changed add-ons
35+
id: changed_addons
36+
run: |
37+
declare -a changed_addons
38+
for addon in ${{ steps.addons.outputs.addons }}; do
39+
if [[ "${{ steps.changed_files.outputs.all }}" =~ $addon ]]; then
40+
for file in ${{ env.MONITORED_FILES }}; do
41+
if [[ "${{ steps.changed_files.outputs.all }}" =~ $addon/$file ]]; then
42+
if [[ ! "${changed_addons[@]}" =~ $addon ]]; then
43+
changed_addons+=("\"${addon}\",");
44+
fi
45+
fi
46+
done
47+
fi
48+
done
49+
50+
changed=$(echo ${changed_addons[@]} | rev | cut -c 2- | rev)
51+
52+
if [[ -n ${changed} ]]; then
53+
echo "Changed add-ons: $changed";
54+
echo "changed=true" >> $GITHUB_OUTPUT;
55+
echo "addons=[$changed]" >> $GITHUB_OUTPUT;
56+
else
57+
echo "No add-on had any monitored files changed (${{ env.MONITORED_FILES }})";
58+
fi
59+
build:
60+
needs: init
61+
runs-on: ubuntu-latest
62+
if: needs.init.outputs.changed == 'true'
63+
name: Build ${{ matrix.arch }} ${{ matrix.addon }} add-on
64+
strategy:
65+
matrix:
66+
addon: ${{ fromJson(needs.init.outputs.changed_addons) }}
67+
arch: ["aarch64", "amd64"]
68+
permissions:
69+
contents: read
70+
packages: write
71+
72+
steps:
73+
- name: Check out repository
74+
uses: actions/checkout@v6.0.1
75+
76+
- name: Get information
77+
id: info
78+
uses: home-assistant/actions/helpers/info@master
79+
with:
80+
path: "./${{ matrix.addon }}"
81+
82+
- name: Check if add-on should be built
83+
id: check
84+
run: |
85+
if [[ "${{ steps.info.outputs.image }}" == "null" ]]; then
86+
echo "Image property is not defined, skipping build"
87+
echo "build_arch=false" >> $GITHUB_OUTPUT;
88+
elif [[ "${{ steps.info.outputs.architectures }}" =~ ${{ matrix.arch }} ]]; then
89+
echo "build_arch=true" >> $GITHUB_OUTPUT;
90+
echo "image=$(echo ${{ steps.info.outputs.image }} | cut -d'/' -f3)" >> $GITHUB_OUTPUT;
91+
if [[ -z "${{ github.head_ref }}" ]] && [[ "${{ github.event_name }}" == "push" ]]; then
92+
echo "BUILD_ARGS=" >> $GITHUB_ENV;
93+
fi
94+
else
95+
echo "${{ matrix.arch }} is not a valid arch for ${{ matrix.addon }}, skipping build";
96+
echo "build_arch=false" >> $GITHUB_OUTPUT;
97+
fi
98+
99+
- name: Login to GitHub Container Registry
100+
if: env.BUILD_ARGS != '--test'
101+
uses: docker/login-action@v3.6.0
102+
with:
103+
registry: ghcr.io
104+
username: ${{ github.repository_owner }}
105+
password: ${{ secrets.GITHUB_TOKEN }}
106+
107+
- name: Build ${{ matrix.addon }} add-on
108+
if: steps.check.outputs.build_arch == 'true'
109+
uses: home-assistant/builder@2025.11.0
110+
with:
111+
args: |
112+
${{ env.BUILD_ARGS }} \
113+
--${{ matrix.arch }} \
114+
--target /data/${{ matrix.addon }} \
115+
--image "${{ steps.check.outputs.image }}" \
116+
--docker-hub "ghcr.io/${{ github.repository_owner }}" \
117+
--addon

.github/workflows/lint.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
schedule:
11+
- cron: "0 0 * * *"
12+
13+
jobs:
14+
find:
15+
name: Find add-ons
16+
runs-on: ubuntu-latest
17+
outputs:
18+
addons: ${{ steps.addons.outputs.addons_list }}
19+
steps:
20+
- name: ⤵️ Check out code from GitHub
21+
uses: actions/checkout@v6.0.1
22+
23+
- name: 🔍 Find add-on directories
24+
id: addons
25+
uses: home-assistant/actions/helpers/find-addons@master
26+
27+
lint:
28+
name: Lint add-on ${{ matrix.path }}
29+
runs-on: ubuntu-latest
30+
needs: find
31+
strategy:
32+
matrix:
33+
path: ${{ fromJson(needs.find.outputs.addons) }}
34+
steps:
35+
- name: ⤵️ Check out code from GitHub
36+
uses: actions/checkout@v6.0.1
37+
38+
- name: 🚀 Run Home Assistant Add-on Lint
39+
uses: frenck/action-addon-linter@v2.21
40+
with:
41+
path: "./${{ matrix.path }}"

.vscode/tasks.json

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "Start Home Assistant",
6+
"type": "shell",
7+
"command": "supervisor_run",
8+
"group": {
9+
"kind": "test",
10+
"isDefault": true
11+
},
12+
"presentation": {
13+
"reveal": "always",
14+
"panel": "new"
15+
},
16+
"problemMatcher": []
17+
},
18+
{
19+
"label": "Start Addon",
20+
"type": "shell",
21+
"command": "ha addons stop \"local_${input:addonName}\"; ha addons start \"local_${input:addonName}\"; docker logs --follow \"addon_local_${input:addonName}\"",
22+
"group": {
23+
"kind": "test",
24+
"isDefault": false
25+
},
26+
"presentation": {
27+
"reveal": "always",
28+
"panel": "new"
29+
},
30+
"problemMatcher": [],
31+
"runOptions": {
32+
"reevaluateOnRerun": false
33+
}
34+
},
35+
{
36+
"label": "Rebuild and Start Addon",
37+
"type": "shell",
38+
"command": "ha addons rebuild --force \"local_${input:addonName}\"; ha addons start \"local_${input:addonName}\"; docker logs --follow \"addon_local_${input:addonName}\"",
39+
"group": {
40+
"kind": "test",
41+
"isDefault": false
42+
},
43+
"presentation": {
44+
"reveal": "always",
45+
"panel": "new"
46+
},
47+
"problemMatcher": []
48+
}
49+
],
50+
"inputs": [
51+
{
52+
"id": "addonName",
53+
"type": "pickString",
54+
"description": "Name of addon (to add your addon to this list, please edit .vscode/tasks.json)",
55+
"options": [
56+
"example",
57+
]
58+
}
59+
]
60+
}

0 commit comments

Comments
 (0)