Skip to content

Commit

Permalink
Merge branch 'home-assistant:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
L0rdShrek authored Nov 14, 2024
2 parents f26e4bc + 606c03d commit 994f83a
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 16 deletions.
32 changes: 19 additions & 13 deletions .github/workflows/builder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
changed: ${{ steps.changed_addons.outputs.changed }}
steps:
- name: Check out the repository
uses: actions/checkout@v4.1.1
uses: actions/checkout@v4.2.2

- name: Get changed files
id: changed_files
Expand Down Expand Up @@ -65,10 +65,13 @@ jobs:
matrix:
addon: ${{ fromJson(needs.init.outputs.changed_addons) }}
arch: ["aarch64", "amd64", "armhf", "armv7", "i386"]
permissions:
contents: read
packages: write

steps:
- name: Check out repository
uses: actions/checkout@v4.1.1
uses: actions/checkout@v4.2.2

- name: Get information
id: info
Expand All @@ -79,28 +82,31 @@ jobs:
- 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;
if [[ "${{ steps.info.outputs.image }}" == "null" ]]; then
echo "Image property is not defined, skipping build"
echo "build_arch=false" >> $GITHUB_OUTPUT;
elif [[ "${{ 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@v3.0.0
uses: docker/login-action@v3.3.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@2024.01.0
uses: home-assistant/builder@2024.08.2
with:
args: |
${{ env.BUILD_ARGS }} \
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
addons: ${{ steps.addons.outputs.addons_list }}
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/checkout@v4.1.1
uses: actions/checkout@v4.2.2

- name: 🔍 Find add-on directories
id: addons
Expand All @@ -33,9 +33,9 @@ jobs:
path: ${{ fromJson(needs.find.outputs.addons) }}
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/checkout@v4.1.1
uses: actions/checkout@v4.2.2

- name: 🚀 Run Home Assistant Add-on Lint
uses: frenck/action-addon-linter@v2.15
uses: frenck/action-addon-linter@v2.18
with:
path: "./${{ matrix.path }}"
41 changes: 41 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,47 @@
"panel": "new"
},
"problemMatcher": []
},
{
"label": "Start Addon",
"type": "shell",
"command": "ha addons stop \"local_${input:addonName}\"; ha addons start \"local_${input:addonName}\"; docker logs --follow \"addon_local_${input:addonName}\"",
"group": {
"kind": "test",
"isDefault": false
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": [],
"runOptions": {
"reevaluateOnRerun": false
}
},
{
"label": "Rebuild and Start Addon",
"type": "shell",
"command": "ha addons rebuild \"local_${input:addonName}\"; ha addons start \"local_${input:addonName}\"; docker logs --follow \"addon_local_${input:addonName}\"",
"group": {
"kind": "test",
"isDefault": false
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": []
}
],
"inputs": [
{
"id": "addonName",
"type": "pickString",
"description": "Name of addon (to add your addon to this list, please edit .vscode/tasks.json)",
"options": [
"example",
]
}
]
}

0 comments on commit 994f83a

Please sign in to comment.