Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 32 additions & 23 deletions .github/workflows/validate-plugin-toml.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
name: Validate Plugin TOML

on:
pull_request:
pull_request_target:
branches:
- master
paths:
- 'plugins/**'

permissions:
pull-requests: write
contents: read
issues: write

jobs:
validate:
Expand All @@ -20,11 +21,12 @@ jobs:
with:
submodules: recursive
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: Get changed plugins
id: changed
run: |
CHANGED_PLUGINS=$(git diff --name-only origin/${{ github.base_ref }}...HEAD | grep '^plugins/' | cut -d'/' -f2 | sort -u | tr '\n' ' ')
CHANGED_PLUGINS=$(git diff --name-only origin/${{ github.base_ref }}...${{ github.event.pull_request.head.sha }} | grep '^plugins/' | cut -d'/' -f2 | sort -u | tr '\n' ' ')
echo "plugins=$CHANGED_PLUGINS" >> $GITHUB_OUTPUT
echo "Changed plugins: $CHANGED_PLUGINS"

Expand Down Expand Up @@ -53,8 +55,6 @@ jobs:
run: |
pnpm validate ${{ steps.changed.outputs.plugins }}
echo "result=success" >> $GITHUB_OUTPUT
# If validation fails (exit 1), continue-on-error keeps the workflow running
# but 'result=success' won't be written to GITHUB_OUTPUT

- name: Post validation comment
if: always() && steps.changed.outputs.plugins != ''
Expand All @@ -72,28 +72,37 @@ jobs:
body = marker + '\n## Plugin TOML Validation Report\n\n> No validation report generated.';
}

const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});

const existing = comments.find(c => c.body && c.body.includes(marker));

if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body,
});
} else {
await github.rest.issues.createComment({
try {
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body,
});

const existing = comments.find(c => c.body && c.body.includes(marker));

if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body,
});
}
} catch (error) {
if (error.status === 403) {
core.warning(`Skipping PR comment because the workflow token cannot write comments: ${error.message}`);
return;
}

throw error;
}

- name: Fail if validation failed
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@
[submodule "plugins/tenant"]
path = plugins/tenant
url = https://github.com/fastapi-practices/tenant.git
[submodule "plugins/api_key_ui"]
path = plugins/api_key_ui
url = https://github.com/yzbf-lin/api_key_ui.git
17 changes: 17 additions & 0 deletions plugins-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,23 @@
"branch": "master"
}
},
{
"plugin": {
"icon": "https://wu-clan.github.io/picx-images-hosting/logo/fba.svg",
"summary": "API Key UI",
"version": "0.0.1",
"description": "API Key 前端管理插件,提供列表、搜索、新增、编辑、启停与复制能力",
"author": "yzbf-lin",
"tags": [
"auth"
]
},
"git": {
"path": "plugins/api_key_ui",
"url": "https://github.com/yzbf-lin/api_key_ui.git",
"branch": "master"
}
},
{
"plugin": {
"icon": "https://wu-clan.github.io/picx-images-hosting/logo/fba.svg",
Expand Down
17 changes: 17 additions & 0 deletions plugins-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,23 @@ export const pluginDataList: PluginData[] = [
"branch": "master"
}
},
{
"plugin": {
"icon": "https://wu-clan.github.io/picx-images-hosting/logo/fba.svg",
"summary": "API Key UI",
"version": "0.0.1",
"description": "API Key 前端管理插件,提供列表、搜索、新增、编辑、启停与复制能力",
"author": "yzbf-lin",
"tags": [
"auth"
]
},
"git": {
"path": "plugins/api_key_ui",
"url": "https://github.com/yzbf-lin/api_key_ui.git",
"branch": "master"
}
},
{
"plugin": {
"icon": "https://wu-clan.github.io/picx-images-hosting/logo/fba.svg",
Expand Down
1 change: 1 addition & 0 deletions plugins/api_key_ui
Submodule api_key_ui added at 94b983
Loading