Skip to content

Commit 0cb2f83

Browse files
committed
✨ new action parameter: Projects sort
1 parent 4095a2b commit 0cb2f83

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

action.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@ inputs:
1717
description: "Control if you want forks count"
1818
required: False
1919
default: True
20+
project_sort_by:
21+
description: "Sorting the projects according to count of number of stars or forks"
22+
required: False
23+
default: 'stars'
2024

2125
runs:
2226
using: "composite"
2327
steps:
2428
- run: python -m pip install PyGithub
2529
shell: bash
26-
- run: python ${{ github.action_path }}/main-script.py ${{ inputs.gh_token }} ${{ inputs.file_name }} ${{ github.workspace }} ${{ inputs.max_repo_description }} ${{ inputs.allow_forks }}
30+
- run: python ${{ github.action_path }}/main-script.py ${{ inputs.gh_token }} ${{ inputs.file_name }} ${{ github.workspace }} ${{ inputs.max_repo_description }} ${{ inputs.allow_forks }} ${{ inputs.project_sort_by }}
2731
shell: bash
2832
branding:
2933
icon: "award"

main-script.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def rewriteContents(old_content, new_content):
1616
start = git.rate_limiting[0]
1717
max_repo_description = int(sys.argv[4])
1818
allow_forks = bool(sys.argv[5])
19+
project_sort_by = sys.argv[6]
1920
print(f'Request left at start of the script: {start}')
2021

2122
user_object = git.get_user()
@@ -51,8 +52,9 @@ def rewriteContents(old_content, new_content):
5152
print(f'Requests Consumed in this process: {start - end}')
5253
print("=====================REPO CHECK ENDS=============================")
5354

55+
sort_key = 'repo_' + project_sort_by
5456
project_data_sorted = dict(
55-
sorted(project_data.items(), key=lambda x: x[1]['repo_stars'])[::-1])
57+
sorted(project_data.items(), key=lambda x: x[1][sort_key])[::-1])
5658

5759

5860
repoName = sys.argv[3].split('/')[-1]

0 commit comments

Comments
 (0)