forked from ChelseaKR/outcome-receipts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrepo-traffic.sh
More file actions
executable file
·23 lines (21 loc) · 809 Bytes
/
Copy pathrepo-traffic.sh
File metadata and controls
executable file
·23 lines (21 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env bash
set -euo pipefail
repository="${1:-ChelseaKR/outcome-receipts}"
captured_at="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
jq -n \
--arg captured_at "$captured_at" \
--arg repository "$repository" \
--argjson views "$(gh api "repos/$repository/traffic/views")" \
--argjson clones "$(gh api "repos/$repository/traffic/clones")" \
--argjson referrers "$(gh api "repos/$repository/traffic/popular/referrers")" \
--argjson paths "$(gh api "repos/$repository/traffic/popular/paths")" \
--argjson repository_state "$(gh repo view "$repository" --json stargazerCount,forkCount,watchers)" \
'{
captured_at: $captured_at,
repository: $repository,
repository_state: $repository_state,
views: $views,
clones: $clones,
referrers: $referrers,
popular_paths: $paths
}'