Skip to content

Auto-update latest HA version #490

Auto-update latest HA version

Auto-update latest HA version #490

name: Auto-update latest HA version
on:
schedule:
- cron: '0 10 * * *'
workflow_dispatch:
jobs:
get-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.REPO_SCOPED_TOKEN }}
- name: Prepare git
run: |
git config user.name "GitHub Action"
git config user.email "[email protected]"
- name: Fetch ha release version
id: ha-version
run: |
HA_VERSION=$(curl -sL https://api.github.com/repos/home-assistant/home-assistant/releases/latest | jq -r ".tag_name")
if [[ -z "$HA_VERSION" || "$HA_VERSION" == "null" ]]; then
echo "Returned HA version is null or empty, exiting."
exit 1
fi
if ! [[ "$HA_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo "HA_VERSION does not contain a version in semver format."
exit 1
fi
echo "Setting appVersion to $HA_VERSION in Chart.yaml"
sed -i "s/^appVersion:.*/appVersion: $HA_VERSION/" charts/home-assistant/Chart.yaml
git add charts/home-assistant/Chart.yaml
echo "UPDATED=true" >> $GITHUB_ENV
git commit -m "Updated Home Assistant version to $HA_VERSION" || EXIT_CODE=$?
if [ "$EXIT_CODE" -ne 0 ]; then
echo "Probably no changes to commit, exiting."
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
# - name: Fetch code server release version
# id: code-server-version
# run: |
# CODE_SERVER_VERSION_WITH_PREFIX=$(curl -sL https://api.github.com/repos/coder/code-server/releases/latest | jq -r ".tag_name")
# if [ -z "$CODE_SERVER_VERSION_WITH_PREFIX" ]; then
# echo "Returned Code Server version is null or empty, exiting."
# exit 1
# fi
# CODE_SERVER_VERSION=$(echo $CODE_SERVER_VERSION_WITH_PREFIX | sed 's/^v//')
# echo "Setting code server version to $CODE_SERVER_VERSION"
# sed -i '/^addons:/,/^\w/{ s/\(tag: \).*$/\1"'$CODE_SERVER_VERSION'"/ }' charts/home-assistant/values.yaml
# git add charts/home-assistant/values.yaml
# git commit -m "Updated code-server version to $CODE_SERVER_VERSION" || EXIT_CODE=$?
# if [ "$EXIT_CODE" -ne 0 ]; then
# echo "Probably no changes to commit, exiting."
# echo "changed=false" >> "$GITHUB_OUTPUT"
# else
# echo "changed=true" >> "$GITHUB_OUTPUT"
# fi
- name: Commit latest release version
run: |
git config user.name "GitHub Action"
git config user.email "[email protected]"
git push
- name: Run second step if the previous was successful
# if: steps.ha-version.outputs.changed == 'true' || steps.code-server-version.outputs.changed == 'true'
if: steps.ha-version.outputs.changed == 'true'
uses: benc-uk/workflow-dispatch@v1
with:
workflow: Release Charts