-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
61 lines (51 loc) · 1.42 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: 'Hash string'
description: 'Hash a string'
inputs:
string:
description: 'The string to hash.'
required: true
separator:
description: 'The separator that is used to join the lines.'
required: false
default: '\n'
method:
description: 'The hashing method to use.'
required: false
default: 'md5sum'
mode:
description: 'The mode to use for formatting. Set to "args" to deduplicate key-value pairs.'
required: false
default: ''
outputs:
hash:
description: 'The hashed string, empty if no string was provided.'
value: ${{ steps.hash.outputs.hash }}
string:
description: 'The string that was hashed.'
value: ${{ steps.format.outputs.string }}
runs:
using: composite
steps:
- uses: myparcelnl/actions/format-string@v4
id: format
with:
string: ${{ inputs.string }}
mode: ${{ inputs.mode }}
sort: true
deduplicate: true
input-separator: ${{ inputs.separator }}
output-separator: ' '
- name: 'Hash string'
id: hash
shell: bash
env:
STRING: ${{ steps.format.outputs.string }}
HASH_METHOD: ${{ inputs.method }}
#language=bash
run: |
if [ -z "$STRING" ]; then
echo "hash=" >> $GITHUB_OUTPUT
exit 0
fi
HASH=$(echo -n "$STRING" | $(echo "$HASH_METHOD") | cut -d ' ' -f 1)
echo "hash=$HASH" >> $GITHUB_OUTPUT