Skip to content

Commit d43b548

Browse files
committed
fix
1 parent 5812eaa commit d43b548

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

.github/workflows/calculate-score.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,22 @@ jobs:
6767
6868
- name: Check for lesson assignments
6969
id: check_lessons
70-
if: github.event_name == 'pull_request'
7170
run: |
72-
# PR 事件:检测 PR 来源仓库(学员 Fork 的仓库)
73-
CHECK_OWNER=${{ github.event.pull_request.head.repo.owner.login }}
74-
CHECK_REPO=${{ github.event.pull_request.head.repo.name }}
75-
STUDENT_NAME=${{ github.actor }}
71+
# 确定要检测的仓库和学员用户名
72+
if [ "${{ github.event_name }}" = "pull_request" ]; then
73+
# PR 事件:检测 PR 来源仓库(学员 Fork 的仓库)
74+
CHECK_OWNER=${{ github.event.pull_request.head.repo.owner.login }}
75+
CHECK_REPO=${{ github.event.pull_request.head.repo.name }}
76+
STUDENT_NAME=${{ github.actor }}
77+
echo "PR 模式:检测仓库 $CHECK_OWNER/$CHECK_REPO,学员 $STUDENT_NAME"
78+
else
79+
# 非 PR 事件:检测当前仓库
80+
REPO_NAME=${{ github.repository }}
81+
CHECK_OWNER=$(echo $REPO_NAME | cut -d'/' -f1)
82+
CHECK_REPO=$(echo $REPO_NAME | cut -d'/' -f2)
83+
STUDENT_NAME=$CHECK_OWNER
84+
echo "非 PR 模式:检测仓库 $CHECK_OWNER/$CHECK_REPO,学员 $STUDENT_NAME"
85+
fi
7686
7787
echo "检测学员 $STUDENT_NAME 在仓库 $CHECK_OWNER/$CHECK_REPO 中的作业"
7888
@@ -220,7 +230,6 @@ jobs:
220230
rm /tmp/decrypted-config.env
221231
222232
- name: Post lesson assignments score to remote API
223-
if: github.event_name == 'pull_request'
224233
run: |
225234
STUDENT_NAME=${{ env.student_name }}
226235

0 commit comments

Comments
 (0)