forked from frenck/action-home-assistant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
120 lines (107 loc) · 3.86 KB
/
action.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
---
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):/config \
$env_file_arg \
--workdir /config \
"ghcr.io/home-assistant/home-assistant:${{ steps.version.outputs.version }}" \
python -m homeassistant \
--config "${{ steps.check.outputs.path }}" \
--script check_config