--- name: "Frenck's Home Assistant Core Configuration Check" description: 🚀 Frenck's GitHub Action for running a Home Assistant config check. author: frenck branding: color: red icon: thumbs-up inputs: path: description: Path to the folder containing the Home Assistant configuration default: "." required: false secrets: description: Alternative secrets file to use required: false version: description: Version to use; dev/beta/stable or a specific version number required: false env_file: description: Possible path to environment file to use required: false runs: using: "composite" steps: - name: 🏗 Check if the configuration is actually there id: check shell: bash run: | path="${{ inputs.path }}" path="${path%/}" if [[ ! -d "${path}" ]]; then echo "::error ::Could not find specified configuration path: ${path}" exit 1 fi if [[ ! -f "${path}/configuration.yaml" ]]; then echo "::error ::Could not find configuration.yaml file in: ${path}" exit 1 fi echo "path=${path}" >> "$GITHUB_OUTPUT" - name: 🏗 Ensure secrets are in place shell: bash run: | if [[ -z "${{ inputs.secrets }}" ]]; then exit 0 fi secrets="${{ inputs.secrets }}" secrets="${secrets%/}" if [[ -d "${secrets}" ]] && [[ -f "${secrets}/secrets.yaml" ]]; then secrets="${secrets}/secrets.yaml" elif [[ -d "${{ steps.check.outputs.path }}/${secrets}" ]] && \ [[ -f "${{ steps.check.outputs.path }}/${secrets}/secrets.yaml" ]]; then secrets="${{ steps.check.outputs.path }}/${secrets}/secrets.yaml" elif [[ -f "${{ steps.check.outputs.path }}/${secrets}" ]]; then secrets="${{ steps.check.outputs.path }}/${secrets}" elif [[ ! -f "${secrets}" ]]; then echo "::error ::Could not find specified secrets file:"\ " ${{ inputs.secrets }}" exit 1 fi cp "${secrets}" "${{ steps.check.outputs.path }}/secrets.yaml" - name: 🏗 Determine & download requested Home Assistant version shell: bash id: version run: | version="${{ inputs.version }}" if [[ -z "${version}" ]]; then if [[ -f "${{ steps.check.outputs.path }}/.HA_VERSION" ]]; then version=$(<"${{ steps.check.outputs.path }}/.HA_VERSION") else echo "::warning ::No specific version found or specified;"\ "Using 'stable' instead. Specify the version in the GitHub"\ "Action or ensure the '.HA_VERSION' file is in your repository." version="stable" fi fi echo "version=${version}" >> "$GITHUB_OUTPUT" docker pull -q "ghcr.io/home-assistant/home-assistant:${version}" - name: 🏗 Register Home Assistant problem matcher shell: bash run: | matcher="${{ github.action_path }}/matcher.json" echo "::add-matcher::${matcher}" - name: 🚀 Run Home Assistant Configuration Check shell: bash # yamllint disable rule:line-length run: | docker run --rm \ --entrypoint "" \ "ghcr.io/home-assistant/home-assistant:${{ steps.version.outputs.version }}" \ python -m homeassistant --version env_file_arg="" if [[ -f "${{ inputs.env_file }}" ]]; then env_file_arg="--env-file ${{ inputs.env_file }}" fi docker run --rm \ --entrypoint "" \ -v $(pwd):/github/workspace \ $env_file_arg \ --workdir /github/workspace \ "ghcr.io/home-assistant/home-assistant:${{ steps.version.outputs.version }}" \ python -m homeassistant \ --config "${{ steps.check.outputs.path }}" \ --script check_config