-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerate_readme.sh
executable file
·55 lines (46 loc) · 1.49 KB
/
generate_readme.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
51
52
53
54
55
#!/usr/bin/env bash
# This script generates the README.md file.
# It requires gh to be installed and configured.
# https://cli.github.com/
#
# Usage: ./generate_readme.sh
org="DynamoDS"
output_file="README.md"
if ! which gh &> /dev/null; then
echo "❕gh is not installed."
echo "Please install it first. https://cli.github.com/"
exit 1
fi
list_repos() {
local org=$1
gh repo list $1 \
--limit 100 \
--no-archived \
--visibility public \
--json nameWithOwner,url \
--template '{{range .}}{{.nameWithOwner}}{{","}}{{.url}}{{"\n"}}{{end}}' | sort -f
}
echo "# Workflows" > $output_file
echo "" >> $output_file
echo "🔍 Getting all repositories"
list_repos $org | while IFS=, read -r repo url; do
echo
echo "ℹ️ Parsing repository: $repo"
workflows=$(gh api /repos/$repo/contents/.github/workflows -q '.[] | select(.type == "file") | .name')
if [ $? -ne 0 ]; then
continue
fi
echo "## [$repo]($url)" >> $output_file
echo "" >> $output_file
echo "Workflow | Status" >> $output_file
echo "---------|--------" >> $output_file
for workflow in $workflows; do
echo "🔹 $workflow"
path="https://github.com/$repo/actions/workflows/$workflow"
badge="https://github.com/$repo/actions/workflows/$workflow/badge.svg"
echo "[$workflow]($path) | [![$workflow]($badge)]($path)" >> $output_file
done
echo "" >> $output_file
done
echo
echo "✅ Readme generated: $output_file"