Skip to content

Commit

Permalink
retrigger
Browse files Browse the repository at this point in the history
Signed-off-by: Hannah Bollar <[email protected]>
  • Loading branch information
hanbollar committed Jan 3, 2024
1 parent 3866892 commit 24fe23e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/kpi.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Count Non-Member Issues and PRs This Month
name: count activity by non-members this month

on:
push: # to delete
Expand All @@ -12,20 +12,24 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2

- name: Count issues and PRs activity by non-members with pagination
- name: count activity by non-members this month
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Function to paginate through API results
# needed in case the count of any of the items gets too large to handle github's default
# for number of items per page of results
function paginate() {
echo 'begin paginate'
url=$1
all_data=""
loop_count=0
while [ "$url" != "null" ]; do
response=$(curl -H "Authorization: token $GITHUB_TOKEN" -s -I "$url")
all_data+=$(curl -H "Authorization: token $GITHUB_TOKEN" -s "$url")
url=$(echo "$response" | grep -oP '(?<=<)(.*?)(?=>; rel="next")')
echo "$loop_count"
loop_count = loop_count+1
done
echo "$all_data"
}
Expand Down
37 changes: 37 additions & 0 deletions hi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Function to paginate through API results
# needed in case the count of any of the items gets too large to handle github's default
# for number of items per page of results
function paginate() {
url=$1
all_data=""
while [ "$url" != "null" ]; do
response=$(curl -H "Authorization: token $GITHUB_TOKEN" -s -I "$url")
all_data+=$(curl -H "Authorization: token $GITHUB_TOKEN" -s "$url")
url=$(echo "$response" | grep -oP '(?<=<)(.*?)(?=>; rel="next")')
done
echo "$all_data"
}

# Get the first day of the current month
month_start=$(date -u +"%Y-%m-01T00:00:00Z")

# Pagination for opened issues
opened_issues_data=$(paginate "https://api.github.com/repos/${{ github.repository }}/issues?state=open&since=$month_start")
opened_issues_count=$(echo "$opened_issues_data" | jq '[.[] | select(.author_association != "MEMBER") and select(.author_association != "OWNER") and (.pull_request == null)] | length')

# Pagination for opened PRs
opened_prs_data=$(paginate "https://api.github.com/repos/${{ github.repository }}/pulls?state=open&since=$month_start")
opened_prs_count=$(echo "$opened_prs_data" | jq '[.[] | select(.author_association != "MEMBER") and select(.author_association != "OWNER")] | length')

# Pagination for closed issues
closed_issues_data=$(paginate "https://api.github.com/repos/${{ github.repository }}/issues?state=closed")
closed_issues_count=$(echo "$closed_issues_data" | jq '[.[] | select(.closed_at >= "'$month_start'") and select(.author_association != "MEMBER") and select(.author_association != "OWNER") and (.pull_request == null)] | length')

# Pagination for closed PRs
closed_prs_data=$(paginate "https://api.github.com/repos/${{ github.repository }}/pulls?state=closed")
closed_prs_count=$(echo "$closed_prs_data" | jq '[.[] | select(.closed_at >= "'$month_start'") and select(.author_association != "MEMBER") and select(.author_association != "OWNER")] | length')

echo "Number of issues opened by non-members this month: $opened_issues_count"
echo "Number of PRs opened by non-members this month: $opened_prs_count"
echo "Number of issues closed by non-members this month: $closed_issues_count"
echo "Number of PRs closed by non-members this month: $closed_prs_count"

0 comments on commit 24fe23e

Please sign in to comment.