Files
test/.gitea/workflows/auto_join.yaml
T
yixinnb 8423940677
Process Python Script on PR / process-python (push) Failing after 2s
添加 .gitea/workflows/auto_join.yaml
2025-03-01 12:19:23 +08:00

34 lines
1.1 KiB
YAML

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 已加入课程"