Add initial GitHub Action
This commit is contained in:
+104
@@ -0,0 +1,104 @@
|
||||
---
|
||||
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
|
||||
|
||||
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 "::set-output name=path::${path}"
|
||||
|
||||
- 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 "::set-output name=version::${version}"
|
||||
|
||||
docker pull "homeassistant/home-assistant:${{ version }}"
|
||||
|
||||
- name: 🚀 Run Home Assistant Configuration Check
|
||||
shell: bash
|
||||
run: |
|
||||
docker run --rm \
|
||||
"homeassistant/home-assistant:${{ steps.version.outputs.version }}" \
|
||||
python -m homeassistant --version
|
||||
|
||||
docker run --rm \
|
||||
-v $(pwd):/github/workspace \
|
||||
--workdir /github/workspace \
|
||||
"homeassistant/home-assistant:${{ steps.version.outputs.version }}" \
|
||||
python -m homeassistant \
|
||||
--config "${{ steps.check.outputs.path }}" \
|
||||
--script check_config
|
||||
Reference in New Issue
Block a user