-
Notifications
You must be signed in to change notification settings - Fork 4
/
action.yml
44 lines (39 loc) · 1.33 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
name: 'Switch Case Action'
description: 'Checks the conditionals-and-values input for the correct one, and if none found, returns default (like a switch case)'
branding:
icon: align-justify
color: orange
inputs:
default:
description: "The value to be returned if no conditionals match"
required: true
conditionals-with-values:
description: "A newline delimited conditional array, split by an arrow (=>)"
required: true
outputs:
value:
description: "The value based on all other logic"
value: ${{ steps.return-value.outputs.value }}
runs:
using: "composite"
steps:
- name: Parse Conditionals and Value
uses: actions-ecosystem/action-regex-match@v2
id: parse-value
with:
text: ${{ inputs.conditionals-with-values }}
regex: 'true\s*=>\s*(.*)?$'
flags: m
- run: "echo ------------- Regex Results ------------"
shell: bash
- run: "echo found - ${{ steps.parse-value.outputs.match != '' }}"
shell: bash
- run: "echo group1 - ${{ steps.parse-value.outputs.group1 }}"
shell: bash
- name: Determine Message
uses: haya14busa/action-cond@v1
id: return-value
with:
cond: ${{ steps.parse-value.outputs.match != '' }}
if_true: ${{ steps.parse-value.outputs.group1 }}
if_false: ${{ inputs.default }}