From de9ecd358b61c373bddf82759ebbdf20b64a1551 Mon Sep 17 00:00:00 2001 From: Florian Bezannier Date: Tue, 17 Mar 2026 08:12:06 +0100 Subject: [PATCH] ci: auto psacc-ha update --- .github/workflows/release.yml | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2f262b1..c731ef8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -78,4 +78,32 @@ jobs: platforms: linux/amd64,linux/arm64,linux/arm/v7 - name: Image digest - run: echo ${{ steps.docker_build.outputs.digest }} \ No newline at end of file + run: echo ${{ steps.docker_build.outputs.digest }} + + update_ha_config: + needs: push_to_registry + name: Update psacc-ha version + runs-on: ubuntu-latest + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-') + steps: + - name: Update psacc-ha version + env: + GH_TOKEN: ${{ secrets.GH_PAT }} + VERSION: ${{ github.ref_name }} + run: | + echo "Updating flobz/psacc-ha config.json to $VERSION" + + # Get current content and SHA + RESPONSE=$(gh api repos/flobz/psacc-ha/contents/psacc-ha/config.json) + FILE_SHA=$(echo "$RESPONSE" | jq -r '.sha') + CURRENT_CONTENT=$(echo "$RESPONSE" | jq -r '.content' | base64 -d) + + # Replace version + NEW_CONTENT=$(echo "$CURRENT_CONTENT" | sed "s/\"version\": \"v[^\"]*\"/\"version\": \"$VERSION\"/") + + # Update file + gh api repos/flobz/psacc-ha/contents/psacc-ha/config.json \ + -X PUT \ + -f message="chore: bump version to $VERSION" \ + -f content="$(echo "$NEW_CONTENT" | base64 -w 0)" \ + -f sha="$FILE_SHA"