Skip to content

添加成员

添加成员 #16

name: Approved - Add Contributor
on:
issues:
types: [labeled]
jobs:
approved-add:
# 仅当打上 approved 标签 + 存在 add-contributor 标签 + 由指定 Owner 操作时运行
if: |
github.event.label.name == 'approved' &&
contains(github.event.issue.labels.*.name, 'add-contributor') &&
contains(fromJSON('["Rocky77JHxu", "xiaohangguo", "wuming082"]'), github.event.sender.login)
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Parse issue and create directory
id: parse
env:
ISSUE_BODY: ${{ github.event.issue.body }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
run: python .github/scripts/parse_issue_and_create.py
- name: Comment and Close (Success)
if: steps.parse.outputs.success == 'true'
uses: actions/github-script@v7
with:
script: |
const { owner, repo } = context.repo;
const issue_number = context.issue.number;
await github.rest.issues.createComment({
owner, repo, issue_number,
body: `**审核通过!**\n\n已为你创建目录:\n\n\`${{ steps.parse.outputs.domain }}/${{ steps.parse.outputs.username }}/\`\n\n欢迎加入项目!🎉`
});
await github.rest.issues.update({
owner, repo, issue_number,
state: 'closed',
state_reason: 'completed'
});
- name: Comment and Close (Failure)
if: steps.parse.outputs.success != 'true'
uses: actions/github-script@v7
with:
script: |
const { owner, repo } = context.repo;
const issue_number = context.issue.number;
await github.rest.issues.createComment({
owner, repo, issue_number,
body: `**审核通过,但格式错误!**\n\n无法解析你的请求。请确保正文包含:\n\`\`\`\n人工智能: WangZipeng\n\`\`\`\n\n请联系管理员协助。`
});
await github.rest.issues.update({
owner, repo, issue_number,
state: 'closed',
state_reason: 'not_planned'
});
- name: Commit and push (on success)
if: steps.parse.outputs.success == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
git diff --staged --quiet || git commit -m "Add ${{ steps.parse.outputs.username }} to ${{ steps.parse.outputs.domain }} (Approved via Issue #${{ github.event.issue.number }})"
git push