From 2c0dc3dc151161c6808f0ee640da2f18c7d4e9af Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 22 May 2024 09:30:16 +0200 Subject: [PATCH] Added additional repository information (#commits, #stars, #contributors) --- action.yml | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index 8e20407e..02a79fb7 100644 --- a/action.yml +++ b/action.yml @@ -81,11 +81,25 @@ runs: echo "GIT_INFO_FILE=$GIT_INFO_FILE" >> $GITHUB_ENV gather_git_info() { - echo "| Attribute | Value |" - echo "| -------------- | ----- |" - echo "| Repository URL | $(git config --get remote.origin.url) |" - echo "| Branch | $(git branch --show-current) |" - echo "| Commit | $(git log -1 --pretty=format:"%H") |" + REPO_URL=$(git config --get remote.origin.url) + BRANCH=$(git branch --show-current) + COMMIT=$(git log -1 --pretty=format:"%H") + NUM_COMMITS=$(git rev-list --count HEAD) + + REPO_PATH=$(echo $REPO_URL | sed -E 's/.*github\.com[:\/](.*)\.git/\1/') + API_URL="https://api.github.com/repos/$REPO_PATH" + + NUM_STARS=$(curl -s $API_URL | jq '.stargazers_count') + NUM_CONTRIBUTORS=$(curl -s $API_URL/contributors | jq 'length') + + echo "| Attribute | Value |" + echo "| ----------------- | ----- |" + echo "| Repository URL | $REPO_URL |" + echo "| Branch | $BRANCH |" + echo "| Commit | $COMMIT |" + echo "| Number of Commits | $NUM_COMMITS |" + echo "| Stars | $NUM_STARS |" + echo "| Contributors | $NUM_CONTRIBUTORS |" echo "" }