Files
class/.github/workflows/people-update.yml
2026-05-03 07:38:19 +08:00

66 lines
2.1 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: Update People Data
on:
issues:
types:
- opened
- edited
- labeled
permissions:
contents: write
issues: write
pull-requests: write
jobs:
update-people:
if: contains(github.event.issue.labels.*.name, 'people-update') || startsWith(github.event.issue.title, 'people:')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
- name: Update src/data/people.ts
env:
ISSUE_BODY: ${{ github.event.issue.body }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
ISSUE_TITLE: ${{ github.event.issue.title }}
run: node scripts/update-people-from-issue.mjs
- name: Create pull request
id: create-pr
uses: peter-evans/create-pull-request@v6
with:
commit-message: "chore: update people data from issue #${{ github.event.issue.number }}"
title: "更新「如今的我们」:#${{ github.event.issue.number }}"
body: |
由 #${{ github.event.issue.number }} 自动生成。
这个 PR 会根据 issue 表单更新 `src/data/people.ts`
- 如果 `slug` 已存在,则修改对应同学资料
- 如果 `slug` 不存在,则新增同学资料
branch: people-update/issue-${{ github.event.issue.number }}
delete-branch: true
labels: people-update
- name: Comment on issue
uses: actions/github-script@v7
with:
script: |
const prUrl = "${{ steps.create-pr.outputs.pull-request-url }}";
const body = prUrl
? `已根据这个 issue 创建更新 PR${prUrl}\n\n如果内容需要再调整,直接编辑 issue 表单即可更新同一个 PR。`
: "这个 issue 没有产生新的文件改动,所以没有创建 PR。";
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body
});