Skip to content

Commit

Permalink
Merge pull request #82 from PalladioSimulator/additional_repo_info
Browse files Browse the repository at this point in the history
Additional repo info
  • Loading branch information
dr6817 authored May 29, 2024
2 parents a0c1cb3 + 0120356 commit 027ecd8
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,28 @@ 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")
REPO_PATH=$(echo $REPO_URL | sed -E 's/.*github\.com[:\/](.*)/\1/')
OWNER=$(echo $REPO_PATH | cut -d'/' -f1)
REPO_NAME=$(echo $REPO_PATH | cut -d'/' -f2 | sed 's/\.git$//')
API_URL="https://api.github.com/repos/$OWNER/$REPO_NAME"
# Get the number of commits using GitHub API and pagination info
NUM_COMMITS=$(curl -s -I "${API_URL}/commits?per_page=1" | grep -i 'link:' | sed -E 's/.*page=([0-9]+)>; rel="last".*/\1/')
NUM_STARS=$(curl -s $API_URL | jq '.stargazers_count // 0')
NUM_CONTRIBUTORS=$(curl -s $API_URL/contributors | jq 'length // 0')
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 ""
}
Expand Down

0 comments on commit 027ecd8

Please sign in to comment.