diff --git a/billing/Earthfile b/billing/Earthfile new file mode 100644 index 0000000..00c2ec0 --- /dev/null +++ b/billing/Earthfile @@ -0,0 +1,9 @@ +VERSION 0.6 + +FROM alpine/git:2.36.3 + +# Estimates monthly active users of a GIT remote repo, based on past commits +active-users: + RUN --secret repoUrl git clone --bare --filter=blob:none $repoUrl repo; + RUN cd repo; \ + git --no-pager log -s --format="%ae" --since=30.days | grep -v @users.noreply.github.com | sort | uniq -c | awk '$1 >= 3 {print $0}' | wc -l diff --git a/billing/README.md b/billing/README.md new file mode 100644 index 0000000..9821e7b --- /dev/null +++ b/billing/README.md @@ -0,0 +1,16 @@ +# Billing utilities +## +active-users +Estimates monthly active users of a GIT remote repo, based on past commits + +Usage: +``` +earthly --secret repoUrl= github.com/earthly/lib/billing+active-users +``` + +### Private repositories +For private repositories use `https` URLs, and pass credentials within the URL: +``` +earthly --secret repoUrl=https://@/host/repo.git github.com/earthly/lib/billing+active-users +``` +> Note: +> For GitHub private repos you need to use a [personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) instead of your password