-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgenerate-userenv-list.sh
executable file
·50 lines (44 loc) · 1.31 KB
/
generate-userenv-list.sh
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
#!/bin/bash
# -*- mode: sh; indent-tabs-mode: nil; sh-basic-offset: 4 -*-
# vim: autoindent tabstop=4 shiftwidth=4 expandtab softtabstop=4 filetype=bash
rickshaw_directory=${1}
userenv_filter=${2}
if pushd ${rickshaw_directory}; then
excludes=""
excludes_file="userenvs/ci-excludes.txt"
if [ -e ${excludes_file} ]; then
while read userenv; do
excludes+="${userenv} "
done < ${excludes_file}
fi
userenvs=$(find userenvs/ -maxdepth 1 -name '*.json' -type f | sed -e 's|userenvs/||' -e 's|\.json||')
# Discard excluded envs
for ex in ${excludes[@]}; do
new=( "${userenvs[@]/$ex}" )
userenvs=$new
done
userenvs_json="["
case "${userenv_filter}" in
"all"|"minimal")
userenvs_json+="\"default\","
;;
esac
case "${userenv_filter}" in
"all"|"unique")
for userenv in ${userenvs}; do
userenvs_json+="\"${userenv}\","
done
;;
esac
userenvs_json=$(echo "${userenvs_json}" | sed -e "s/,$//")
userenvs_json+="]"
echo "userenvs_json=${userenvs_json}"
if [ -n "${GITHUB_OUTPUT}" ]; then
echo "userenvs=${userenvs_json}" >> ${GITHUB_OUTPUT}
else
echo "WARNING: \$GITHUB_OUTPUT not defined"
fi
exit 0
else
exit 1
fi