diff --git a/.github/workflows/onpush_builder.yaml b/.github/workflows/onpush_builder.yaml index e971678e2..a597264b1 100644 --- a/.github/workflows/onpush_builder.yaml +++ b/.github/workflows/onpush_builder.yaml @@ -1,6 +1,6 @@ # yamllint disable rule:line-length -# inspired from https://github.com/Poeschl/Hassio-Addons ---- +# Build all add-ons, continue matrix even if one fails + name: Builder env: @@ -15,70 +15,26 @@ on: - "**/config.*" jobs: - correct_path_filters: - if: ${{ github.repository_owner == 'alexbelgium' && !contains(github.event.head_commit.message, 'nobuild') }} + list-addons: runs-on: ubuntu-latest - steps: - - name: â†Šī¸ Checkout - uses: actions/checkout@v4 - - name: Update path_filters - run: | - # Init - echo "Starting" - - # Go through all folders, add to filters if not existing - for f in $( find -- * -maxdepth 0 -type d | sort -r ); do - if [ -f "$f"/config.json ]; then - - # Add to file - if ! grep "$f:" ".github/paths-filter.yml"; then - echo "$f: $f/config.*" >> ".github/paths-filter.yml" - fi - - # Identify addons with true images - if [ "$(jq '.image' "$f/config.json")" != null ]; then - sed -i "/$f/ s/ # Image : yes//g" ".github/paths-filter.yml" - sed -i "/$f/ s/$/ # Image : yes/" ".github/paths-filter.yml" - fi - fi - done - - # Sort yaml - sort -t= ".github/paths-filter.yml" -o ".github/paths-filter.yml" - - name: Commit if needed - uses: EndBug/add-and-commit@v9 - with: - commit: -u - message: "GitHub bot : scripts executable" - default_author: github_actions - - check-addon-changes: - runs-on: ubuntu-latest - needs: [correct_path_filters] outputs: - changedAddons: ${{ steps.filter.outputs.changes }} + addons: ${{ steps.find_addons.outputs.addons }} steps: - - name: â†Šī¸ Checkout + - name: Checkout Repo uses: actions/checkout@v4 - - name: 📂 Detect changed files - uses: dorny/paths-filter@v3 - id: filter - with: - filters: .github/paths-filter.yml - - correct-CRLF: - if: ${{ needs.check-addon-changes.outputs.changedAddons != '[]' }} - needs: check-addon-changes - uses: ./.github/workflows/weekly_crlftolf.yaml + - id: find_addons + run: | + # Find all folders (max depth 2) that have a config.json and output as JSON array + ADDONS=$(find . -maxdepth 2 -type f -name "config.json" | sed 's|^\./||;s|/config.json||' | jq -R -s -c 'split("\n")[:-1]') + echo "addons=$ADDONS" >> $GITHUB_OUTPUT make-executable: - if: ${{ needs.check-addon-changes.outputs.changedAddons != '[]' }} - needs: [check-addon-changes, correct-CRLF] + needs: list-addons runs-on: ubuntu-latest - strategy: + strategy: fail-fast: false matrix: - addon: ${{ fromJSON(needs.check-addon-changes.outputs.changedAddons) }} + addon: ${{ fromJSON(needs.list-addons.outputs.addons) }} steps: - name: Checkout Repo uses: actions/checkout@v4 @@ -87,12 +43,7 @@ jobs: echo "Starting" git pull origin master git config core.filemode true - # shellcheck disable=SC2086,SC2046 - #git update-index --chmod=+x $(find "$path" -type f -iname "*.sh") - chmod u+x $(find "$path" -type f -iname "*.sh") || true - #git commit -am "fixing the script permissions..." - env: - path: "./${{ matrix.addon }}" + chmod u+x $(find "${{ matrix.addon }}" -type f -iname "*.sh") || true - name: Commit if needed uses: EndBug/add-and-commit@v9 with: @@ -101,12 +52,12 @@ jobs: default_author: github_actions normalize-spaces: - if: ${{ needs.check-addon-changes.outputs.changedAddons != '[]' }} - needs: [check-addon-changes, make-executable, correct-CRLF] + needs: [list-addons, make-executable] runs-on: ubuntu-latest strategy: + fail-fast: false matrix: - addon: ${{ fromJSON(needs.check-addon-changes.outputs.changedAddons) }} + addon: ${{ fromJSON(needs.list-addons.outputs.addons) }} steps: - name: Checkout Repo uses: actions/checkout@v4 @@ -114,11 +65,8 @@ jobs: run: | set -e cd "${{ matrix.addon }}" - # Find all files (excluding .git) find . -type f ! -path "./.git/*" | while read -r file; do - # Replace all non-breaking spaces (U+00A0) with ASCII space LC_ALL=C sed -i 's/\xC2\xA0/ /g' "$file" - # Optionally, replace other weird unicode spaces if needed (can be added here) done - name: Commit if normalization was needed uses: EndBug/add-and-commit@v9 @@ -128,29 +76,29 @@ jobs: default_author: github_actions lint_config: - if: ${{ needs.check-addon-changes.outputs.changedAddons != '[]' }} - needs: [check-addon-changes, normalize-spaces, correct-CRLF, make-executable, correct_path_filters] + needs: [list-addons, normalize-spaces, make-executable] runs-on: ubuntu-latest strategy: + fail-fast: false matrix: - addon: ${{ fromJSON(needs.check-addon-changes.outputs.changedAddons) }} + addon: ${{ fromJSON(needs.list-addons.outputs.addons) }} steps: - - name: â†Šī¸ Checkout + - name: Checkout Repo uses: actions/checkout@v4 - - name: 🔎 Run Home Assistant Add-on Lint + - name: Run Home Assistant Add-on Lint uses: frenck/action-addon-linter@v2 with: path: "./${{ matrix.addon }}" build: - if: ${{ needs.check-addon-changes.outputs.changedAddons != '[]' }} - needs: [check-addon-changes, lint_config] + needs: [list-addons, lint_config] runs-on: ubuntu-latest environment: CR_PAT name: Build ${{ matrix.arch }} ${{ matrix.addon }} add-on strategy: + fail-fast: false matrix: - addon: ${{ fromJSON(needs.check-addon-changes.outputs.changedAddons) }} + addon: ${{ fromJSON(needs.list-addons.outputs.addons) }} arch: ["aarch64", "amd64", "armv7"] steps: @@ -159,17 +107,13 @@ jobs: - name: Resolve Symlinks run: | - # Find all symlinks and replace them with the real files or directories find . -type l | while read -r link; do target="$(readlink -f "$link")" if [ -z "$target" ]; then echo "Skipping broken symlink: $link" continue fi - rm "$link" - - # If target is directory, copy contents into link's parent directory if [ -d "$target" ]; then mkdir -p "$link" cp -a "$target/." "$link/" @@ -189,19 +133,14 @@ jobs: env: HEAD: "${{ github.head_ref }}" run: | - # shellcheck disable=SC2157,SC2086 if [[ "${{ steps.info.outputs.architectures }}" =~ ${{ matrix.arch }} ]]; then - # shellcheck disable=SC2129 echo "build_arch=true" >> $GITHUB_OUTPUT; - # shellcheck disable=SC2129 echo "image=$(echo ${{ steps.info.outputs.image }} | cut -d'/' -f3)" >> $GITHUB_OUTPUT; if [[ -z "$HEAD" ]] && [[ "${{ github.event_name }}" == "push" ]]; then - # shellcheck disable=SC2129 echo "BUILD_ARGS=" >> $GITHUB_ENV; fi else echo "${{ matrix.arch }} is not a valid arch for ${{ matrix.addon }}, skipping build"; - # shellcheck disable=SC2129 echo "build_arch=false" >> $GITHUB_OUTPUT; fi @@ -219,6 +158,7 @@ jobs: - name: Build ${{ matrix.addon }} add-on id: builderstep if: steps.check.outputs.build_arch == 'true' + continue-on-error: true # <-- This makes the matrix continue if a build fails uses: home-assistant/builder@2025.03.0 env: CAS_API_KEY: ${{ secrets.CAS_API_KEY }} @@ -232,22 +172,20 @@ jobs: --addon make-changelog: - if: ${{ needs.check-addon-changes.outputs.changedAddons != '[]' }} - needs: [check-addon-changes, build] + needs: [list-addons, build] runs-on: ubuntu-latest strategy: + fail-fast: false matrix: - addon: ${{ fromJSON(needs.check-addon-changes.outputs.changedAddons) }} + addon: ${{ fromJSON(needs.list-addons.outputs.addons) }} steps: - name: Checkout Repo uses: actions/checkout@v4 - name: Update changelog for minor versions run: | echo "Starting" - # Git pull git pull || true - cd "$path" - # Get version + cd "${{ matrix.addon }}" if [ -f config.yaml ]; then version="$(sed -e '/version/!d' -e 's/.*version: //' config.yaml)" elif [ -f config.json ]; then @@ -256,22 +194,15 @@ jobs: else exit 1 fi - # Exit if test if [[ "$version" == *"test"* ]]; then exit 0; fi - # Create changelog touch CHANGELOG.md - # If the version does not exist if ! grep -q "$version" CHANGELOG.md; then first_line="$(sed -n '/./p' CHANGELOG.md | head -n 1)" - # If the first line does not start with - if [[ "$first_line" != "-"* ]]; then sed -i "1i\- Minor bugs fixed" CHANGELOG.md fi sed -i "1i\## $version ($(date '+%d-%m-%Y'))" CHANGELOG.md - #fi fi - env: - path: "./${{ matrix.addon }}" - name: Commit if needed uses: EndBug/add-and-commit@v9 with: