diff --git a/.gitea/workflows/auto_join.yaml b/.gitea/workflows/auto_join.yaml index 111c163..6a3da1d 100644 --- a/.gitea/workflows/auto_join.yaml +++ b/.gitea/workflows/auto_join.yaml @@ -5,7 +5,10 @@ on: jobs: add-to-team: - runs-on: ubuntu-latest + runs-on: auto_judgement_py + env: + ISSUE_AUTHOR: "${{ github.event.issue.user.login }}" + ISSUE_BODY: "${{ github.event.issue.body }}" steps: - name: Output GitHub Context id: output-context @@ -18,7 +21,7 @@ jobs: echo "-------------------------" done - - name: Check if issue title starts with [join] + - name: Check basic id: check-title run: | if [[ "${{ github.event.issue.title }}" == "[join]"* ]]; then @@ -31,15 +34,46 @@ jobs: if: steps.check-title.outputs.valid_title == 'true' run: | # 设置变量 - GITEA_URL="http://10.2.2.195" # 替换为你的 Gitea 地址 TOKEN="${{ secrets.YX_TOKEN }}" # 替换为你的 Gitea Access Token TEAM_ID="9" # 替换为目标团队的 ID org:class-member - ISSUE_USER="${{ github.event.issue.user.login }}" # 调用 Gitea API 将用户加入团队 curl -X PUT \ -H "Authorization: token $TOKEN" \ -H "Content-Type: application/json" \ - "$GITEA_URL/api/v1/teams/$TEAM_ID/members/$ISSUE_USER" + "{$api_url}/teams/$TEAM_ID/members/$ISSUE_AUTHOR" - echo "$ISSUE_USER 已加入课程" \ No newline at end of file + echo "请求成功 ( $ISSUE_AUTHOR" + + - name: 保存学生信息 + run: | + python3 join_class.py + + - name: comment and close issue + if: steps.check-title.outputs.valid_title == 'true' + env: + ID: ${{ github.event.number }} + run: | + + - name: Comment on issue + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # 使用默认的 GITHUB_TOKEN + ISSUE_NUMBER: ${{ github.event.issue.number }} + run: | + COMMENT_BODY="test" + curl -s -X POST \ + -H "Authorization: token $GITHUB_TOKEN" \ + -H "Accept: application/json" \ + {$api_url}/repos/${{ github.repository }}/issues/$ISSUE_NUMBER/comments \ + -d "{\"body\": \"$COMMENT_BODY\"}" + + - name: Close issue + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ISSUE_NUMBER: ${{ github.event.issue.number }} + run: | + curl -s -X PATCH \ + -H "Authorization: token $GITHUB_TOKEN" \ + -H "Accept: application/json" \ + {$api_url}/repos/${{ github.repository }}/issues/$ISSUE_NUMBER \ + -d '{"state": "closed"}'