-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
action.yml
61 lines (57 loc) · 1.92 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
60
61
name: 'Home Assistant helper: version-push'
description: 'GitHub action helper: version-push'
inputs:
key:
required: true
default: ''
description: "JSON key to replace version with, e.g. supervisor, homeassistant.default or hassos[] to replace for all properties in hassos."
key-description:
required: false
description: "Human Friendly description of key which is beeing changed for git commit message."
version:
required: true
default: ''
channel:
default: 'dev'
runs:
using: "composite"
steps:
- shell: bash
id: validate-input
env:
INPUTS_KEY: ${{ inputs.key }}
INPUTS_VERSION: ${{ inputs.version }}
INPUTS_KEY_DESCRIPTION: ${{ inputs.key-description }}
run: |
if [[ -z "$INPUTS_KEY" ]];then
echo "::error::Missing required key 'key' input!"
exit 1
elif [[ -z "$INPUTS_VERSION" ]];then
echo "::error::Missing required key 'version' input!"
exit 1
fi
if [[ -z "$INPUTS_KEY_DESCRIPTION" ]];then
echo "key-description=$INPUTS_KEY" >> "$GITHUB_OUTPUT"
else
echo "key-description=$INPUTS_KEY_DESCRIPTION" >> "$GITHUB_OUTPUT"
fi
- shell: bash
run: git clone --depth 1 https://github.com/home-assistant/version.git /tmp/version
- shell: bash
env:
INPUTS_KEY: ${{ inputs.key }}
INPUTS_VERSION: ${{ inputs.version }}
INPUTS_CHANNEL: ${{ inputs.channel }}
run: |
temp=$(mktemp)
jq ".$INPUTS_KEY |= \"$INPUTS_VERSION\"" "/tmp/version/$INPUTS_CHANNEL.json" > "${temp}"
mv "${temp}" "/tmp/version/$INPUTS_CHANNEL.json"
- shell: bash
env:
INPUTS_VERSION: ${{ inputs.version }}
run: |
cd /tmp/version
git commit -am "Bump ${{ steps.validate-input.outputs.key-description }} to $INPUTS_VERSION"
git push
- shell: bash
run: rm -rf /tmp/version