From 2c0dc3dc151161c6808f0ee640da2f18c7d4e9af Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 22 May 2024 09:30:16 +0200 Subject: [PATCH 1/5] 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 "" } From 263dc252af07ce73f26c214214e4ce511399e9d9 Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 22 May 2024 09:55:20 +0200 Subject: [PATCH 2/5] Always use latest version to be able to test --- action.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index 02a79fb7..c07f1f34 100644 --- a/action.yml +++ b/action.yml @@ -54,11 +54,13 @@ runs: shell: bash # Uses the latest Retriever or the Retriever with the same version that this action has run: | - if [[ "${{ env.action_version }}" == "main" ]]; then - echo "retriever=${{ github.api_url }}/repos/PalladioSimulator/Palladio-ReverseEngineering-Retriever/releases/latest" >> $GITHUB_ENV - else - echo "retriever=${{ github.api_url }}/repos/PalladioSimulator/Palladio-ReverseEngineering-Retriever/releases/tags/${{ env.action_version }}" >> $GITHUB_ENV - fi + echo "retriever=${{ github.api_url }}/repos/PalladioSimulator/Palladio-ReverseEngineering-Retriever/releases/latest" >> $GITHUB_ENV + + # if [[ "${{ env.action_version }}" == "main" ]]; then + # echo "retriever=${{ github.api_url }}/repos/PalladioSimulator/Palladio-ReverseEngineering-Retriever/releases/latest" >> $GITHUB_ENV + # else + # echo "retriever=${{ github.api_url }}/repos/PalladioSimulator/Palladio-ReverseEngineering-Retriever/releases/tags/${{ env.action_version }}" >> $GITHUB_ENV + # fi - name: Gather Retriever Info shell: bash From fb6f8440e9b3f877ec9bc0fbdfea4e33df2b7f13 Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 22 May 2024 10:04:19 +0200 Subject: [PATCH 3/5] Debug --- action.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index c07f1f34..670d8476 100644 --- a/action.yml +++ b/action.yml @@ -91,8 +91,14 @@ runs: 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 "API_URL" + echo $API_URL + + git log + + NUM_STARS=$(curl -s $API_URL | jq '.stargazers_count // 0') + NUM_CONTRIBUTORS=$(curl -s $API_URL/contributors | jq 'length // 0') echo "| Attribute | Value |" echo "| ----------------- | ----- |" From 1f6f0ed7e10d4c77b83cfc5506a728d2bf771137 Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 22 May 2024 10:26:24 +0200 Subject: [PATCH 4/5] Fixed API_URL and NUM_COMMITS --- action.yml | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/action.yml b/action.yml index 670d8476..5e248a8b 100644 --- a/action.yml +++ b/action.yml @@ -86,17 +86,14 @@ runs: 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" - - - echo "API_URL" - echo $API_URL - - git log + 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') From cc5fd858971ca9b8d7857c2ac59b95f64a076412 Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 29 May 2024 09:21:05 +0200 Subject: [PATCH 5/5] Revert "Always use latest version to be able to test" This reverts commit 263dc252af07ce73f26c214214e4ce511399e9d9. --- action.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/action.yml b/action.yml index 5e248a8b..a381c314 100644 --- a/action.yml +++ b/action.yml @@ -54,13 +54,11 @@ runs: shell: bash # Uses the latest Retriever or the Retriever with the same version that this action has run: | - echo "retriever=${{ github.api_url }}/repos/PalladioSimulator/Palladio-ReverseEngineering-Retriever/releases/latest" >> $GITHUB_ENV - - # if [[ "${{ env.action_version }}" == "main" ]]; then - # echo "retriever=${{ github.api_url }}/repos/PalladioSimulator/Palladio-ReverseEngineering-Retriever/releases/latest" >> $GITHUB_ENV - # else - # echo "retriever=${{ github.api_url }}/repos/PalladioSimulator/Palladio-ReverseEngineering-Retriever/releases/tags/${{ env.action_version }}" >> $GITHUB_ENV - # fi + if [[ "${{ env.action_version }}" == "main" ]]; then + echo "retriever=${{ github.api_url }}/repos/PalladioSimulator/Palladio-ReverseEngineering-Retriever/releases/latest" >> $GITHUB_ENV + else + echo "retriever=${{ github.api_url }}/repos/PalladioSimulator/Palladio-ReverseEngineering-Retriever/releases/tags/${{ env.action_version }}" >> $GITHUB_ENV + fi - name: Gather Retriever Info shell: bash