From 8423940677af949ef52ede659508b9afacb19739 Mon Sep 17 00:00:00 2001 From: yixinnb <1667511790@qq.com> Date: Sat, 1 Mar 2025 12:19:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20.gitea/workflows/auto=5Fjo?= =?UTF-8?q?in.yaml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/auto_join.yaml | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .gitea/workflows/auto_join.yaml diff --git a/.gitea/workflows/auto_join.yaml b/.gitea/workflows/auto_join.yaml new file mode 100644 index 0000000..22ae657 --- /dev/null +++ b/.gitea/workflows/auto_join.yaml @@ -0,0 +1,34 @@ +name: Add User to Team on Issue +on: + issues: + types: [opened] + +jobs: + add-to-team: + runs-on: ubuntu-latest + steps: + - name: Check if issue title starts with [join] + id: check-title + run: | + if [[ "${{ github.event.issue.title }}" == [join]* ]]; then + echo "::set-output name=valid_title::true" + else + echo "::set-output name=valid_title::false" + fi + + - name: Add user to team + 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" + + echo "$ISSUE_USER 已加入课程" \ No newline at end of file