-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-scc-on-repos.sh
executable file
·47 lines (37 loc) · 1.34 KB
/
run-scc-on-repos.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
#!/bin/bash
# Variables
GITHUB_API_URL="https://github.cms.gov/api/v3"
ORGANIZATION="pecos-application-development"
TOKEN=$GITHUB_TOKEN # Set your environment variable to your GitHub Token
SCC_LOG_LOC=$(readlink -f ./scc_reports)
# Function to fetch repositories from the organization
fetch_repositories() {
curl -s -H "Authorization: token $TOKEN" "$GITHUB_API_URL/orgs/$ORGANIZATION/repos?per_page=100&page=$1"
}
cd $1
# Iterate through pages of repositories
page=1
while true; do
# Fetch repositories for the current page
response=$(fetch_repositories $page)
# Check if the response contains repositories
echo $response
if [[ $response == "[ ]" ]]; then
echo "No more repositories found."
break
fi
repo_names=$(echo "$response" | jq -r '.[] | .name')
for repo in $repo_names; do
echo "Processing repository: $repo"
# Add your code to process each repository here
# For example:
clone_url=$(echo "$response" | jq -r ".[] | select(.name == \"$repo\") | .clone_url")
echo "Cloning repository from: $clone_url"
git clone $clone_url || echo "failed or already exits"
cd $repo
scc --format json > "$SCC_LOG_LOC/pecos_${repo}.json"
cd ..
done
# Increment page number for the next iteration
page=$((page + 1))
done