@@ -51,18 +51,18 @@ jobs:
5151 # Get the repository name from GITHUB_REPOSITORY
5252 REPO_NAME=$(echo "$GITHUB_REPOSITORY" | cut -d'/' -f2)
5353 echo "Repository: $REPO_NAME"
54-
54+
5555 # Count PRs merged yesterday into main branch
5656 # Using GitHub API to search for PRs merged on yesterday's date
5757 YESTERDAY="${{ steps.yesterday.outputs.yesterday }}"
58-
58+
5959 # Search for PRs merged yesterday
6060 PR_COUNT=$(curl --silent \
6161 --header "Authorization: token $GITHUB_TOKEN" \
6262 --header "Accept: application/vnd.github.v3+json" \
6363 "https://api.github.com/search/issues?q=repo:$GITHUB_REPOSITORY+is:pr+is:merged+merged:$YESTERDAY..$YESTERDAY+base:main" \
6464 | jq '.total_count')
65-
65+
6666 echo "PRs merged yesterday: $PR_COUNT"
6767 echo "pr_count=$PR_COUNT" >> $GITHUB_OUTPUT
6868
@@ -74,18 +74,18 @@ jobs:
7474 run : |
7575 YESTERDAY="${{ steps.yesterday.outputs.yesterday }}"
7676 PR_COUNT="${{ steps.count_prs.outputs.pr_count }}"
77-
77+
7878 # Get OAuth token
7979 token=$(oauth2l fetch --scope https://www.googleapis.com/auth/spreadsheets)
80-
80+
8181 # Read existing data to check if yesterday's row exists
8282 spreadsheet_data=$(curl --silent --header "Authorization: Bearer $token" \
8383 https://sheets.googleapis.com/v4/spreadsheets/"$SPREADSHEET_ID"/values/"$SHEET_NAME"!A:C)
84-
84+
8585 # Check if yesterday's date exists in column A
8686 current_date_index=$(echo "$spreadsheet_data" | jq --arg yesterday "$YESTERDAY" \
8787 '(.values | map(.[0])) | (index($yesterday) | if . == null then null else . + 1 end)')
88-
88+
8989 if [ "$current_date_index" == "null" ]; then
9090 # Date doesn't exist, append new row with PR count in column C
9191 curl --silent --header "Authorization: Bearer $token" \
@@ -102,4 +102,4 @@ jobs:
102102 --data "{\"values\":[[$PR_COUNT]]}" \
103103 https://sheets.googleapis.com/v4/spreadsheets/"$SPREADSHEET_ID"/values/"$SHEET_NAME"!C"$current_date_index":C"$current_date_index"?valueInputOption=USER_ENTERED
104104 echo "Updated row $current_date_index for $YESTERDAY with $PR_COUNT PRs merged"
105- fi
105+ fi
0 commit comments