-
Notifications
You must be signed in to change notification settings - Fork 0
/
gh-legitify
executable file
·59 lines (52 loc) · 1.05 KB
/
gh-legitify
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
#!/usr/bin/env bash
set -e
if ! type -p go >/dev/null; then
echo "Go not found on the system" >&2
exit 1
fi
if [ ! -d "./legitify" ]; then
echo "Initializing legitify..."
git clone --depth 1 https://github.com/Legit-Labs/legitify.git &>/dev/null
fi
# Default values
REPO_NAME=""
SCORECARD=""
ORG_NAME=""
# Parse command line arguments
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
--repo)
REPO_NAME="$2"
shift
shift
;;
--scorecard)
SCORECARD="$2"
shift
shift
;;
--org)
ORG_NAME="$2"
shift
shift
;;
*)
echo "Error: Unknown option: $key"
exit 1
;;
esac
done
# Build parameter string
PARAMS=""
if [ -n "$REPO_NAME" ]; then
PARAMS="$PARAMS --repo=$REPO_NAME"
fi
if [ -n "$SCORECARD" ]; then
PARAMS="$PARAMS --scorecard=$SCORECARD"
fi
if [ -n "$ORG_NAME" ]; then
PARAMS="$PARAMS --org=$ORG_NAME"
fi
# Run legitify with the provided parameters
cd legitify; LEGITIFY_TOKEN=$(gh auth token) go run ./... analyze --namespace repository $PARAMS; cd ..