-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
action.yml
59 lines (54 loc) · 2.02 KB
/
action.yml
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
name: 'Home Assistant helper: info'
description: 'GitHub action helper: info'
inputs:
path:
description: The relative dir path to where the type files are
required: false
default: '.'
outputs:
architectures:
description: Returns the supported architectures
value: ${{ steps.info.outputs.architectures }}
image:
description: Returns the image defined in the config file for add-ons if any
value: ${{ steps.info.outputs.image }}
version:
description: Returns the version defined in the config file for add-ons if any
value: ${{ steps.info.outputs.version }}
runs:
using: "composite"
steps:
- shell: bash
id: info
env:
ACTION_PATH: ${{ github.action_path }}
INPUTS_PATH: ${{ inputs.path }}
run: |
archs=[]
image=""
version=""
mkdir -p "$ACTION_PATH/bin"
wget -q -O "$ACTION_PATH/bin/yq" https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
chmod a+x "$ACTION_PATH/bin/yq"
echo "$ACTION_PATH/bin" >> "$GITHUB_PATH"
for file_type in json yml yaml; do
if [[ -f "$INPUTS_PATH/build.${file_type}" ]]; then
archs=$(yq e -N -M '.build_from | keys' -o=json -I=0 "$INPUTS_PATH/build.${file_type}")
break
elif [[ -f "$INPUTS_PATH/config.${file_type}" ]]; then
archs=$(yq e -N -M '.arch' -o=json -I=0 "$INPUTS_PATH/config.${file_type}")
break
fi
done
for file_type in json yml yaml; do
if [[ -f "$INPUTS_PATH/config.${file_type}" ]]; then
image=$(yq e -N -M '.image' -o=json -I=0 "$INPUTS_PATH/config.${file_type}")
version=$(yq e -N -M '.version' -o=json -I=0 "$INPUTS_PATH/config.${file_type}")
fi
done
echo "Architectures: $archs"
echo "Image: $image"
echo "Version: $version"
echo "architectures=$archs" >> "$GITHUB_OUTPUT"
echo "image=$image" >> "$GITHUB_OUTPUT"
echo "version=$version" >> "$GITHUB_OUTPUT"