diff --git a/.github/workflows/agent-address-pr2933-comments.yml b/.github/workflows/agent-address-pr2933-comments.yml new file mode 100644 index 0000000000..167373622d --- /dev/null +++ b/.github/workflows/agent-address-pr2933-comments.yml @@ -0,0 +1,190 @@ +name: Address PR 2933 review comments + +on: + push: + branches: + - agent/migrate-app-config-map-names + paths: + - .github/workflows/agent-address-pr2933-comments.yml + +permissions: + contents: write + +jobs: + apply-fixes: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Apply reviewed fixes + shell: bash + run: | + python3 - <<'PY' + from pathlib import Path + + def replace(path: str, old: str, new: str, *, expected: int = 1) -> None: + file = Path(path) + text = file.read_text() + count = text.count(old) + if count != expected: + raise SystemExit(f"{path}: expected {expected} occurrence(s), found {count}: {old!r}") + file.write_text(text.replace(old, new)) + + # Repository shell formatting. + replace( + ".templates/01-custom_script.sh", + '''if [ ! -f /config/configuration.yaml ] && [ ! -f /config/configuration.json ]; then + CONFIGLOCATION="/config" + CONFIGFILEBROWSER="/app_configs/${HOSTNAME/-/_}/$slug.sh" + else + CONFIGLOCATION="/config/addons_autoscripts" + CONFIGFILEBROWSER="/homeassistant/addons_autoscripts/$slug.sh" + fi''', + '''if [ ! -f /config/configuration.yaml ] && [ ! -f /config/configuration.json ]; then + CONFIGLOCATION="/config" + CONFIGFILEBROWSER="/app_configs/${HOSTNAME/-/_}/$slug.sh" + else + CONFIGLOCATION="/config/addons_autoscripts" + CONFIGFILEBROWSER="/homeassistant/addons_autoscripts/$slug.sh" + fi''', + ) + + # app_config maps the app's own persistent storage to /config inside the container. + replace( + "cleanuparr/rootfs/ha_entrypoint.sh", + "# We symlink /app/config → /app_configs/cleanuparr (HA persistent storage)", + "# We symlink /app/config → /config (HA persistent app_config storage)", + ) + replace( + "cleanuparr/rootfs/ha_entrypoint.sh", + 'HA_DATA_DIR="/app_configs/cleanuparr"', + 'HA_DATA_DIR="/config"', + ) + replace( + "cleanuparr/Dockerfile", + "# Our wrapper symlinks /app/config → HA app_config and starts ./Cleanuparr directly.", + "# Our wrapper symlinks /app/config → the /config app_config mount and starts ./Cleanuparr directly.", + ) + + # Keep qBittorrent migration output aligned with the actual source/destination paths. + replace( + "qbittorrent/rootfs/etc/cont-init.d/00-folders.sh", + 'echo "Files moved to /app_configs/$HOSTNAME/openvpn" > /homeassistant/addons_config/qBittorrent/migrated', + 'echo "Files moved to /app_configs/$HOSTNAME/qBittorrent" > /homeassistant/addons_config/qBittorrent/migrated', + ) + replace( + "qbittorrent/rootfs/etc/cont-init.d/00-folders.sh", + 'bashio::log.yellow "... moved files from /config/addons_config/qBittorrent to /app_configs/$HOSTNAME/qBitorrent (must be accessed with my Filebrowser addon)"', + 'bashio::log.yellow "... moved files from /homeassistant/addons_config/qBittorrent to /app_configs/$HOSTNAME/qBittorrent (must be accessed with my Filebrowser addon)"', + ) + replace( + "qbittorrent/rootfs/etc/cont-init.d/00-folders.sh", + 'bashio::log.yellow "... moved config.yaml from /config/addons_config/qbittorrent to /app_configs/$HOSTNAME"', + 'bashio::log.yellow "... moved config.yaml from /homeassistant/addons_config/qbittorrent to /app_configs/$HOSTNAME"', + ) + replace( + "qbittorrent/rootfs/etc/cont-init.d/00-folders.sh", + "/homeassistant/addons_autoscrips/qbittorrent.sh", + "/homeassistant/addons_autoscripts/qbittorrent.sh", + expected=3, + ) + replace( + "qbittorrent/rootfs/etc/cont-init.d/00-folders.sh", + 'bashio::log.yellow "... moved qbittorrent.sh from /config/addons_autoscripts to /app_configs/$HOSTNAME"', + 'bashio::log.yellow "... moved qbittorrent.sh from /homeassistant/addons_autoscripts/qbittorrent.sh to /app_configs/$HOSTNAME/qbittorrent.sh"', + ) + replace( + "qbittorrent/rootfs/etc/cont-init.d/92-qbit_manage.sh", + "/app_configs/$HOSTNAME/qbit_manage/qbit_manage.yaml", + "/app_configs/$HOSTNAME/qbit_manage/qbit_manage.yml", + ) + + # Documentation path and wording corrections requested by review. + replace( + "calibre/CHANGELOG.md", + "This avoids the addon to mess with your homeassistant configuration folder", + "This prevents the add-on from modifying your Home Assistant configuration folder", + ) + replace( + "calibre/CHANGELOG.md", + "For more information, see here : https://developers.home-assistant.io/blog/2023/11/06/public-addon-config/ https://github.com/alexbelgium/hassio-addons/issues/1154", + "For more information, see [the Home Assistant documentation](https://developers.home-assistant.io/blog/2023/11/06/public-addon-config/) and [issue #1154](https://github.com/alexbelgium/hassio-addons/issues/1154).", + ) + replace( + "filebrowser/CHANGELOG.md", + "Files are now located in the addon config file, that can be accessed from the app_configs folder from my filebrowser or cloudcommander addons.", + "Files are now located in the add-on config folder, which was exposed through the legacy /addon_configs path in the Filebrowser and Cloud Commander add-ons.", + ) + replace( + "filebrowser/CHANGELOG.md", + "Homeassistant config accessible in /homeassistant folder ; all addons config in /addons_config ; this addon config in /config", + "Home Assistant config accessible in /homeassistant; all add-on config in the legacy /addon_configs path; this add-on config in /config", + ) + + for path in ( + "fireflyiii_data_importer/CHANGELOG.md", + "guacamole/CHANGELOG.md", + "photoprism/CHANGELOG.md", + "radarr/CHANGELOG.md", + "requestrr/CHANGELOG.md", + "unpackerr/CHANGELOG.md", + ): + replace( + path, + "This avoids the addon to mess with your homeassistant configuration folder", + "This prevents the add-on from modifying your Home Assistant configuration folder", + ) + + replace( + "mealie/CHANGELOG.md", + "/app_configs/db21ed7f_mealie", + "/addon_configs/db21ed7f_mealie", + expected=4, + ) + replace("mealie/CHANGELOG.md", "backuped", "backed up") + replace("mealie/CHANGELOG.md", "occured", "occurred") + replace( + "mealie/README.md", + "/homeassistant/addons_config/xxx-mealie/config.yaml", + "/app_configs/xxx-mealie/config.yaml", + ) + replace( + "unpackerr/CHANGELOG.md", + "Any modifications needs to be done manually", + "Any modifications need to be done manually", + ) + replace( + "whoogle/CHANGELOG.md", + "all Mealie data to be backuped with the addon", + "all Whoogle data to be backed up with the add-on", + ) + replace( + "gitea/README.md", + "/app_configs/gitea/app.ini", + "/app_configs//app.ini", + expected=2, + ) + replace( + "webtrees/README.md", + "but /root/app_configs ([HA documentation]", + "but in /app_configs//config.yaml ([HA documentation]", + ) + replace( + "spotify_to_plex/README.md", + "/app_configs/", + "/app_configs/", + ) + PY + + - name: Validate and commit + shell: bash + run: | + git diff --check + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add -A + git rm .github/workflows/agent-address-pr2933-comments.yml + git commit -m "Address PR review comments" + git push