-
Notifications
You must be signed in to change notification settings - Fork 1
/
scanner.sh
42 lines (41 loc) · 1.57 KB
/
scanner.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
#!/bin/bash
# $1 - "project.clj" or "deps.edn"
if [[ -n $INPUT_DIRECTORY ]]; then
if [[ "$INPUT_VERBOSE" == true ]]; then
echo "Moving to $GITHUB_WORKSPACE$INPUT_DIRECTORY"
fi
cd "$GITHUB_WORKSPACE$INPUT_DIRECTORY" || exit
fi
if [[ "$INPUT_VERBOSE" == true ]]; then
echo "Finding all $1 files"
fi
mapfile -t array < <(find . -name "$1")
if [[ $INPUT_INCLUDE_SUBDIRECTORIES != true ]]; then
if [[ $1 == "project.clj" ]] && [[ "${array[*]}" == *"./project.clj"* ]]; then
array=("./project.clj")
elif [[ $1 == "deps.edn" ]] && [[ "${array[*]}" == *"./deps.edn"* ]]; then
array=("./deps.edn")
else
array=()
fi
fi
for i in "${array[@]}"
do
if [[ "$INPUT_VERBOSE" == true ]]; then
echo "Converting $i to pom.xml and summitting dependencies to Dependabot"
fi
i=${i/.}
cljdir=$GITHUB_WORKSPACE$INPUT_DIRECTORY${i//\/$1}
cd "$cljdir" || exit
if [[ $1 == "project.clj" ]]; then
lein pom
mkdir projectclj
mv pom.xml projectclj/
maven-dependency-submission-linux-x64 --token "$GITHUB_TOKEN" --repository "$GITHUB_REPOSITORY" --branch-ref "$GITHUB_REF" --sha "$GITHUB_SHA" --directory "${cljdir}/projectclj" --job-name "${INPUT_DIRECTORY}${i}/projectclj"
else
clojure -X:deps mvn-pom
mkdir depsedn
mv pom.xml depsedn/
maven-dependency-submission-linux-x64 --token "$GITHUB_TOKEN" --repository "$GITHUB_REPOSITORY" --branch-ref "$GITHUB_REF" --sha "$GITHUB_SHA" --directory "${cljdir}/depsedn" --job-name "${INPUT_DIRECTORY}${i}/depsedn"
fi
done