-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yaml
More file actions
68 lines (57 loc) · 1.59 KB
/
Copy pathaction.yaml
File metadata and controls
68 lines (57 loc) · 1.59 KB
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
name: Parallel run
description: Runs any count of task in parallel
author: Artemis Kushner
branding:
icon: maximize
color: blue
inputs:
working-directory:
type: string
commands:
required: true
type: string
runs:
using: composite
steps:
# This is a cross-platform composite action that needs yq.
# It's not preinstalled on Windows runners.
# See https://github.com/actions/runner-images/issues/7443#issuecomment-1514597691
- name: Make yq tool available on Windows runners
if: runner.os == 'Windows'
run: choco install yq
shell: bash
- name: Run tasks
shell: bash
run: |
set -f
set -o pipefail
pids=()
command_name=()
errors=()
INPUT=$(cat <<-END
${{ inputs.commands }}
END
);
# if ${{ inputs.working-directory != '' }}; then
# cd ${{ inputs.working-directory }}
# fi
# Reading commands
while IFS=: read -r COMMAND_NAME COMMAND_CALL; do
eval "$COMMAND_CALL" & pids+=($!)
command_name+=("$COMMAND_NAME")
done < <(echo "$INPUT" | yq '.[]')
# Waiting until all commands finished
for i in "${!pids[@]}"; do
if ! wait "${pids[$i]}"; then
errors+=($i)
fi
done
# Checks if there are errors
if [ ${#errors[@]} -ne 0 ]; then
echo "Errors occurred in the following steps:"
for error in "${errors[@]}"; do
echo " - ${command_name[$error]}"
done
exit 1
fi
exit 0