更多issue模板

This commit is contained in:
2026-05-03 10:31:05 +08:00
Unverified
parent d7a7cf6fb9
commit 983217f740
6 changed files with 408 additions and 0 deletions
@@ -0,0 +1,71 @@
name: Review Issues Without Template
on:
issues:
types:
- opened
permissions:
issues: write
jobs:
label-without-template:
if: ${{ !github.event.issue.pull_request }}
runs-on: ubuntu-latest
steps:
- name: Add review label when no template is used
uses: actions/github-script@v7
with:
script: |
const reviewLabel = "needs-review";
const templateLabels = new Set([
"people-update",
"photo-update",
"site-suggestion",
]);
const issue = context.payload.issue;
const labels = issue.labels.map((label) => label.name);
const body = issue.body || "";
const title = issue.title || "";
const hasTemplateLabel = labels.some((label) => templateLabels.has(label));
const hasTemplateTitle =
title.startsWith("people:") ||
title.startsWith("photo:") ||
title.startsWith("suggestion:");
const hasTemplateFields =
body.includes("### slug") ||
body.includes("### topic") ||
body.includes("### 建议涉及的网站部分");
if (hasTemplateLabel || hasTemplateTitle || hasTemplateFields) {
return;
}
try {
await github.rest.issues.getLabel({
owner: context.repo.owner,
repo: context.repo.repo,
name: reviewLabel,
});
} catch (error) {
if (error.status !== 404) {
throw error;
}
await github.rest.issues.createLabel({
owner: context.repo.owner,
repo: context.repo.repo,
name: reviewLabel,
color: "fbca04",
description: "Issue did not use a repository template and needs manual review.",
});
}
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
labels: [reviewLabel],
});
+66
View File
@@ -0,0 +1,66 @@
name: Update Photo Data
on:
issues:
types:
- opened
- edited
- labeled
permissions:
contents: write
issues: write
pull-requests: write
jobs:
update-photo:
if: contains(github.event.issue.labels.*.name, 'photo-update') || startsWith(github.event.issue.title, 'photo:')
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 photo topic data
env:
ISSUE_BODY: ${{ github.event.issue.body }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
ISSUE_TITLE: ${{ github.event.issue.title }}
run: node scripts/update-photo-topic-from-issue.mjs
- name: Create pull request
id: create-pr
uses: peter-evans/create-pull-request@v6
with:
commit-message: "chore: update photo data from issue #${{ github.event.issue.number }}"
title: "更新照片墙:#${{ github.event.issue.number }}"
body: |
由 #${{ github.event.issue.number }} 自动生成。
这个 PR 会根据 issue 表单更新 `src/data/photo-topics/<topic>.ts`
- 如果同一专题内已有相同 `title`,则修改对应照片
- 如果没有相同 `title`,则追加一张新照片
- 如果填写了 `cover`,则同步更新专题封面
branch: photo-update/issue-${{ github.event.issue.number }}
delete-branch: true
labels: photo-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
});