Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CI linting and building #2

Merged
merged 12 commits into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 22 additions & 33 deletions .github/workflows/builder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ jobs:
runs-on: ubuntu-latest
name: Initialize builds
outputs:
changed_addons: ${{ steps.changed_addons.outputs.addons }}
changed: ${{ steps.changed_addons.outputs.changed }}
changed: ${{ steps.check.outputs.changed }}
steps:
- name: Check out the repository
uses: actions/[email protected]
Expand All @@ -27,43 +26,33 @@ jobs:
id: changed_files
uses: jitterbit/get-changed-files@v1

- name: Find add-on directories
id: addons
uses: home-assistant/actions/helpers/find-addons@master

- name: Get changed add-ons
id: changed_addons
- name: Check if monitored files changed
id: check
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
declare -a changed
for file in ${{ env.MONITORED_FILES }}; do
if [[ -n ${changed} ]]; then
break
fi
done

changed=$(echo ${changed_addons[@]} | rev | cut -c 2- | rev)
if [[ "${{ steps.changed_files.outputs.all }}" =~ $file ]]; then
changed=true
fi
done

if [[ -n ${changed} ]]; then
echo "Changed add-ons: $changed";
echo "::set-output name=changed::true";
echo "::set-output name=addons::[$changed]";
echo "A monitored file changed.";
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "No add-on had any monitored files changed (${{ env.MONITORED_FILES }})";
echo "No monitored files changed.";
fi
build:
needs: init
runs-on: ubuntu-latest
if: needs.init.outputs.changed == 'true'
name: Build ${{ matrix.arch }} ${{ matrix.addon }} add-on
name: Build add-on
strategy:
matrix:
addon: ${{ fromJson(needs.init.outputs.changed_addons) }}
arch: ["amd64", "armv7", "aarch64"]

steps:
Expand All @@ -74,20 +63,20 @@ jobs:
id: info
uses: home-assistant/actions/helpers/info@master
with:
path: "./${{ matrix.addon }}"
path: "./"

- 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";
echo "::set-output name=image::$(echo ${{ steps.info.outputs.image }} | cut -d'/' -f3)";
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 "::set-output name=build_arch::false";
echo "${{ matrix.arch }} is not a valid arch for this add-on, skipping build";
echo "build_arch=false" >> $GITHUB_OUTPUT
fi

- name: Login to GitHub Container Registry
Expand All @@ -98,13 +87,13 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build ${{ matrix.addon }} add-on
- name: Build add-on
if: steps.check.outputs.build_arch == 'true'
uses: home-assistant/builder@master
with:
args: |
${{ env.BUILD_ARGS }} \
--${{ matrix.arch }} \
--target /data/${{ matrix.addon }} \
--target /data/ \
--image "${{ steps.check.outputs.image }}" \
--addon
21 changes: 2 additions & 19 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,14 @@ on:
- main

jobs:
find:
name: Find add-ons
runs-on: ubuntu-latest
outputs:
addons: ${{ steps.addons.outputs.addons_list }}
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/[email protected]

- name: 🔍 Find add-on directories
id: addons
uses: home-assistant/actions/helpers/find-addons@master

lint:
name: Lint add-on ${{ matrix.path }}
name: Lint add-on
runs-on: ubuntu-latest
needs: find
strategy:
matrix:
path: ${{ fromJson(needs.find.outputs.addons) }}
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/[email protected]

- name: 🚀 Run Home Assistant Add-on Lint
uses: frenck/action-addon-linter@v2
with:
path: "./${{ matrix.path }}"
path: "./"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This addon allows you to run [Ghostfolio][] on your Home Assistant server based

![Ghostfolio Version](https://img.shields.io/badge/dynamic/json?label=Ghostfolio%20Version&url=https%3A%2F%2Fraw.githubusercontent.com%2Flildude%2Fha-addon-ghostfolio%2Fmain%2Fbuild.json&query=%24.args.ghostfolio_version)
![Ingress](https://img.shields.io/badge/dynamic/json?label=Ingress&query=%24.ingress&url=https%3A%2F%2Fraw.githubusercontent.com%2Flildude%2Fha-addon-ghostfolio%2Fmain%2Fconfig.json)
![Supported Architecture](https://img.shields.io/badge/dynamic/json?color=green&label=Arch&query=%24.arch&url=https%3A%2F%2Fraw.githubusercontent.com%2Flildude%2Fha-addon-ghostfolio%2Fmain%2Fconfig.json)
![Supported Architectures](https://img.shields.io/badge/dynamic/json?color=green&label=Arch&query=%24.arch&url=https%3A%2F%2Fraw.githubusercontent.com%2Flildude%2Fha-addon-ghostfolio%2Fmain%2Fconfig.json)

| Light Mode | Dark Mode |
| ----------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
Expand Down
2 changes: 1 addition & 1 deletion build.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"ghostfolio_version": "2.65.0"
},
"labels": {
"org.opencontainers.image.title": "Home Assistant Add-on: Ghostfolio",
"org.opencontainers.image.title": "Home Assistant Add-on: Ghostfolio TESTME",
"org.opencontainers.image.description": "Privacy-first, open source dashboard for your personal finances.",
"org.opencontainers.image.source": "https://github.com/lildude/ha-addon-ghostfolio/",
"org.opencontainers.image.licenses": "MIT"
Expand Down
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@
"jwt_secret_key": "str?"
},
"codenotary": "[email protected]",
"image": "ghcr.io/lildude/ha-addon-ghostfolio/ghostfolio-{arch}"
"image": "ghcr.io/lildude/ha-addon-ghostfolio-{arch}"
}
Loading