14
14
with :
15
15
fetch-depth : 10
16
16
17
+ - name : Get merge commit hash
18
+ id : merge_commit
19
+ with :
20
+ fetch-depth : 10
21
+
22
+ - name : Get current commit details
23
+ id : commit_info
24
+ run : |
25
+ commit_author=$(git log --format='%an' -1)
26
+ commit_email=$(git log --format='%ae' -1)
27
+ echo "Current commit author is $commit_author ($commit_email)"
28
+ echo "commit_author=$commit_author" >> "$GITHUB_ENV"
29
+ echo "commit_email=$commit_email" >> "$GITHUB_ENV"
30
+
17
31
- name : Get merge commit hash
18
32
id : merge_commit
19
33
run : |
@@ -25,14 +39,36 @@ jobs:
25
39
# Merge commit has maintainer's name so we get name from second last commit
26
40
- name : Get original author's name
27
41
id : original_author
42
+ merge_commit=$(git log --merges --pretty=format:%H -1 $GITHUB_SHA)
43
+ echo "Found merge commit : $merge_commit"
44
+ # echo "::set-output name=merge_commit::$merge_commit"
45
+ echo "merge_commit=$merge_commit" >> "$GITHUB_ENV"
46
+
47
+ - name : Set original author
28
48
run : |
29
- echo "Passed merge commit: $merge_commit"
30
- echo "$(git log --format='%ae' -n 2 $merge_commit)"
31
- original_author=$(git log --format='%an' -n 2 $merge_commit | tail -n 1)
32
- original_email=$(git log --format='%ae' -n 2 $merge_commit | tail -n 1)
33
- echo "Author of original commit is $original_author ($original_email)"
34
- # echo "::set-output name=original_author::$original_author"
49
+ if [ -n "$merge_commit" ] && [ "$GITHUB_SHA" = "$merge_commit" ]; then
50
+ original_author=$(git log --format='%an' -n 2 $merge_commit | tail -n 1)
51
+ original_email=$(git log --format='%ae' -n 2 $merge_commit | tail -n 1)
52
+ echo "Author of original commit is $original_author ($original_email)"
53
+ else
54
+ original_author=$commit_author
55
+ original_email=$commit_email
56
+ echo "No merge commit found. Setting original author as $commit_author($commit_email)."
57
+ fi
35
58
echo "original_author=$original_author" >> "$GITHUB_ENV"
59
+ echo "original_email=$original_email" >> "$GITHUB_ENV"
60
+
61
+ # # Merge commit has maintainer's name so we get name from second last commit
62
+ # - name: Get original author's name
63
+ # id: original_author
64
+ # run: |
65
+ # echo "Passed merge commit: $merge_commit"
66
+ # echo "$(git log --format='%ae' -n 2 $merge_commit)"
67
+ # original_author=$(git log --format='%an' -n 2 $merge_commit | tail -n 1)
68
+ # original_email=$(git log --format='%ae' -n 2 $merge_commit | tail -n 1)
69
+ # echo "Author of original commit is $original_author ($original_email)"
70
+ # # echo "::set-output name=original_author::$original_author"
71
+ # echo "original_author=$original_author" >> "$GITHUB_ENV"
36
72
37
73
38
74
- name : Check if there are any changes in submissions dir
@@ -58,22 +94,17 @@ jobs:
58
94
with :
59
95
script : core.setFailed('More than one submissions are not allowed at once.')
60
96
61
- # # TODO(hetul): Get github profile from email https://api.github.com/search/users?q=EMAIL
62
- # - if: ${{ (steps.changes.outputs.src == 'true') && (steps.changes.outputs.src_count == 1) }}
63
- # name: Get author's name from last commit
64
- # id: author_name
65
- # run: |
66
- # # author_name=$(git log -1 --pretty=format:'%an' -- "${{ steps.changes.outputs.src_files }}")
67
- # author_name=$("${{ github.event.commits[0].author.name }}")
68
- # echo Last author $author_name
69
- # echo "{author_name}={$author_name}" >> $GITHUB_OUTPUT
70
-
71
97
- if : ${{ (steps.changes.outputs.src == 'true') && (steps.changes.outputs.src_count == 1) }}
72
98
name : Install Python
73
99
uses : actions/setup-python@v5
74
100
with :
75
101
python-version : " 3.10"
76
102
103
+ - if : ${{ (steps.changes.outputs.src == 'true') && (steps.changes.outputs.src_count == 1) }}
104
+ name : Install dependencies
105
+ run : |
106
+ python -m pip install --upgrade pip
107
+ pip install -r session_2/challenge/requirements.txt
77
108
- if : ${{ (steps.changes.outputs.src == 'true') && (steps.changes.outputs.src_count == 1) }}
78
109
name : Install dependencies
79
110
run : |
@@ -88,11 +119,11 @@ jobs:
88
119
filename=$(basename "${{ steps.changes.outputs.src_files }}")
89
120
filename_without_extension="${filename%.*}" # Remove extension
90
121
echo "Author name: $original_author | Submission name: $filename_without_extension"
91
- python -m scripts.leaderboard --github_name="${{ steps.author_name.outputs.author_name }} " --prompt="$filename_without_extension"
122
+ python -m scripts.leaderboard --github_name="$original_author " --prompt="$filename_without_extension"
92
123
93
- # - if: ${{ (steps.changes.outputs.src == 'true') && (steps.changes.outputs.src_count == 1) }}
94
- # name: Commit changes
95
- # uses: EndBug/add-and-commit@v9
96
- # with:
97
- # message: Updated leaderboard
98
- # default_author: github_actions
124
+ - if : ${{ (steps.changes.outputs.src == 'true') && (steps.changes.outputs.src_count == 1) }}
125
+ name : Commit changes
126
+ uses : EndBug/add-and-commit@v9
127
+ with :
128
+ message : Updated leaderboard
129
+ default_author : github_actions
0 commit comments