-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgithub-actions-link
More file actions
executable file
·105 lines (90 loc) · 3.13 KB
/
github-actions-link
File metadata and controls
executable file
·105 lines (90 loc) · 3.13 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env bash
set -o errexit -o errtrace -o noclobber -o nounset -o pipefail
IFS=$'\n\t'
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
project_dir=$(cd "$(dirname "$script_dir")/.." && pwd)
cd "$project_dir" || exit
# String type (drupal or symfony) from start of name
function strip-project-type() {
name=$1
if [[ "$name" =~ ^(drupal(-module)?|symfony)/(.+) ]]; then
name="${BASH_REMATCH[3]}"
fi
echo "$name"
}
find templates -type l -delete
for template_dir in templates/*; do
template_name=$(basename "$template_dir")
echo "$template_name"
echo
project_type=""
if [[ "$template_name" =~ ^drupal-module ]]; then
project_type="drupal-module"
elif [[ "$template_name" =~ ^drupal- ]]; then
project_type="drupal"
elif [[ "$template_name" =~ ^symfony- ]]; then
project_type="symfony"
else
(>&2 echo "Unknown template type: $template_name")
exit 1
fi
# General config files.
# We first check for files on the config folder and then we check for project
# specific files (in effect letting projects override the general config
# files).
for config_dir in config "config/$project_type"; do
echo "$config_dir"
# Some config files are hidden
GLOBIGNORE=".:.."
for config_file in "$config_dir"/*; do
if [ -f "$config_file" ]; then
ln -sf "../../$config_file" "$template_dir/"
fi
done
done
for f in $(find github/workflows/ -name '*.yaml' | sort); do
source_file_name=''
# Note: / is NOT a regex delimiter here, but an actual /, i.e. a directory separator.
if [[ "$f" =~ /drupal-module/ ]]; then
if [[ "$project_type" == "drupal-module" ]]; then
source_file_name="$(basename "$(dirname "$f")")/$(basename "$f")"
fi
elif [[ "$f" =~ /drupal/ ]]; then
if [[ "$project_type" == "drupal" ]]; then
source_file_name="$(basename "$(dirname "$f")")/$(basename "$f")"
fi
elif [[ "$f" =~ /symfony/ ]]; then
if [[ "$project_type" == "symfony" ]]; then
source_file_name="$(basename "$(dirname "$f")")/$(basename "$f")"
fi
else
source_file_name=$(basename "$f")
fi
if [[ -n "$source_file_name" ]]; then
# Link GitHub Actions workflow file
target_dir="$template_dir/.github/workflows"
mkdir -p "$target_dir"
ln -sf "../../../../github/workflows/$source_file_name" "$target_dir/$(strip-project-type "$source_file_name")"
# Check if we need a language configuration as well
language_name=${source_file_name%.yaml}
config_dir=""
# Check for project_type specific configuration first.
if [ -d "config/$project_type/$language_name" ]; then
config_dir="config/$project_type/$language_name"
elif [ -d "config/$language_name" ]; then
config_dir="config/$language_name"
fi
if [[ -n "$config_dir" ]]; then
# Some config files are hidden
GLOBIGNORE=".:.."
for config_file in "$config_dir"/*; do
if [ -f "$config_file" ]; then
ln -sf "../../$config_file" "$template_dir/"
fi
done
fi
fi
done
find "$template_dir" -type l -ls
echo
done