chore: remove ci

This commit is contained in:
chenos
2026-04-10 20:32:56 +08:00
parent e2b676a3d0
commit ecffbd4ce7
-161
View File
@@ -1,161 +0,0 @@
name: PR Changelog Review
# on:
# pull_request:
# types: [opened, edited]
permissions:
pull-requests: write
contents: read
models: read
jobs:
changelog-review:
runs-on: ubuntu-latest
if: ${{ github.event.action == 'opened' || (github.event.action == 'edited' && github.event.changes.body) }}
steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.NOCOBASE_APP_ID }}
private-key: ${{ secrets.NOCOBASE_APP_PRIVATE_KEY }}
repositories: nocobase
skip-token-revoke: true
- name: Get GitHub App User ID
id: get-user-id
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Detect Changelog changes
id: changelog-changed
uses: actions/github-script@v7
with:
script: |
const oldBody = context.payload.changes?.body?.from || "";
const newBody = context.payload.pull_request.body || "";
if (context.payload.action === "opened") {
return true;
}
function extractChangelog(text) {
const regex = /### Changelog([\s\S]*?)(###|$)/i;
const match = text.match(regex);
return match ? match[1].trim() : "";
}
const oldChangelog = extractChangelog(oldBody);
const newChangelog = extractChangelog(newBody);
return oldChangelog !== newChangelog;
- name: Skip if no changelog changes
if: steps.changelog-changed.outputs.result != 'true'
run: |
echo "No Changelog changes detected, skipping review."
exit 0
- name: Extract changelog from PR body
id: extract
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const body = context.payload.pull_request.body || "";
function extract(lang) {
const regex = new RegExp(`\\|\\s*${lang}\\s*\\|\\s*(.*?)\\s*\\|`, "i");
const match = body.match(regex);
return match ? match[1].trim() : "";
}
const en = extract("🇺🇸 English");
const zh = extract("🇨🇳 Chinese");
return JSON.stringify({ en, zh });
- name: Check if changelog exists
id: check
run: |
EN=$(echo '${{ steps.extract.outputs.result }}' | jq -r .en)
ZH=$(echo '${{ steps.extract.outputs.result }}' | jq -r .zh)
if [ -z "$EN" ] && [ -z "$ZH" ]; then
echo "missing=both" >> $GITHUB_OUTPUT
elif [ -z "$EN" ]; then
echo "missing=en" >> $GITHUB_OUTPUT
elif [ -z "$ZH" ]; then
echo "missing=zh" >> $GITHUB_OUTPUT
else
echo "missing=none" >> $GITHUB_OUTPUT
fi
- name: Comment if changelog is missing
if: steps.check.outputs.missing != 'none'
uses: actions/github-script@v7
with:
github-token: ${{ steps.app-token.outputs.token }}
script: |
let msg;
if ("${{ steps.check.outputs.missing }}" === "both") {
msg = "⚠️ Please provide a changelog in both English and Chinese before merging.";
} else if ("${{ steps.check.outputs.missing }}" === "en") {
msg = "⚠️ Please provide the changelog in **English**.";
} else {
msg = "⚠️ Please provide the changelog in **Chinese**.";
}
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: msg
});
- name: Call GitHub Models API for review
if: steps.check.outputs.missing == 'none'
id: review
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CHANGELOG: ${{ steps.extract.outputs.result }}
run: |
EN=$(echo "$CHANGELOG" | jq -r .en)
ZH=$(echo "$CHANGELOG" | jq -r .zh)
RESPONSE=$(curl -s "https://models.github.ai/inference/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-d "{
\"model\": \"openai/gpt-4o\",
\"messages\": [
{
\"role\": \"system\",
\"content\": \"Please assume you are a technical user seeing this changelog for the first time (not involved in development and without reading the code). Check if the changelog meets the following criteria: 1. Clear understanding: The user can immediately understand what feature was changed, its impact scope, and the purpose of the change without needing background knowledge. 2. Precise wording: Avoid vague terms like \\\"fixed display issue,\\\" \\\"optimized logic,\\\" or \\\"bug fix.\\\" Specify the exact scenario, problem, and what was changed. 3. Value clarity: The changelog clearly communicates the benefit for users, such as improved experience, new features, or resolved issues. 4. Consistent format: Tags (module names), verbs, punctuation, and spacing are consistent, enabling quick scanning. 5. No internal jargon: Avoid internal codes, abbreviations, or implementation details only developers understand. If the changelog does not meet these criteria, please rewrite it into a concise, clear, user-facing description without changing the original meaning in English and Chinese.\"
},
{
\"role\": \"user\",
\"content\": \"English: $EN\nChinese: $ZH\"
}
]
}")
echo "API RESPONSE: $RESPONSE"
REVIEW=$(echo "$RESPONSE" | jq -r '.choices[0].message.content')
echo "review<<EOF" >> $GITHUB_OUTPUT
echo "$REVIEW" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Post review as PR comment
if: steps.check.outputs.missing == 'none'
uses: actions/github-script@v7
with:
github-token: ${{ steps.app-token.outputs.token }}
script: |
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: `### 🤖 AI Changelog Review\n${{ steps.review.outputs.review }}`
});