fix: use jq to grab total commits
This commit is contained in:
@@ -21,14 +21,10 @@ jobs:
|
||||
|
||||
- name: Process Statistics and Update README
|
||||
run: |
|
||||
URL="http://gitea-http:3000/api/v1/repos/search?committer=patrick&priority_owner_id=1"
|
||||
USER_URL="http://gitea-http:3000/api/v1/users/patrick/heatmap"
|
||||
RAW_DATA=$(wget -qO- --header="Authorization: token ${{ secrets.GITHUB_TOKEN }}" "$USER_URL")
|
||||
TOTAL_COMMITS=$(echo "$RAW_DATA" | grep -o '"contributions":[0-9]*' | sed 's/"contributions"://' | awk '{s+=$1} END {print s}')
|
||||
|
||||
if [ -z "$TOTAL_COMMITS" ] || [ "$TOTAL_COMMITS" -eq 0 ]; then
|
||||
TOTAL_COMMITS=20 # Fallback to the local count if API fails
|
||||
fi
|
||||
RAW_DATA=$(wget -qO- --header="Authorization: token ${{ secrets.GITHUB_TOKEN }}" "$USER_URL")
|
||||
TOTAL_COMMITS=$(echo "$RAW_DATA" | jq '. | map(.contributions) | add')
|
||||
|
||||
echo "Global Commit Velocity: $TOTAL_COMMITS"
|
||||
echo "COMMIT_VELOCITY=$TOTAL_COMMITS" >> $GITHUB_ENV
|
||||
|
||||
Reference in New Issue
Block a user