Files
test/.gitea/workflows/auto_join.yaml
T
yixinnb 4b884c8b49
Process Python Script on PR / process-python (push) Failing after 1s
更新 .gitea/workflows/auto_join.yaml
2025-03-01 12:36:24 +08:00

45 lines
1.6 KiB
YAML

name: Add User to Team on Issue
on:
issues:
types: [opened]
jobs:
add-to-team:
runs-on: ubuntu-latest
steps:
- name: Output GitHub Context
id: output-context
run: |
# Loop through all properties in the github context
for key in $(echo '${{ toJson(github) }}' | jq -r 'keys[]'); do
value=$(echo '${{ toJson(github) }}' | jq -r .$key)
echo "Property Name: $key"
echo "Property Value: $value"
echo "-------------------------"
done
- 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 已加入课程"