mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-03 02:28:23 +08:00
4
.github/workflows/docker-test-cont.yml
vendored
4
.github/workflows/docker-test-cont.yml
vendored
@@ -43,11 +43,9 @@ jobs:
|
|||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
script: |
|
script: |
|
||||||
const PR = JSON.parse(process.env.PULL_REQUEST)
|
const PR = JSON.parse(process.env.PULL_REQUEST)
|
||||||
const body = PR.body
|
|
||||||
const number = PR.number
|
const number = PR.number
|
||||||
const sender = PR.user.login
|
|
||||||
const { default: identify } = await import('${{ github.workspace }}/scripts/workflow/test-route/identify.mjs')
|
const { default: identify } = await import('${{ github.workspace }}/scripts/workflow/test-route/identify.mjs')
|
||||||
return identify({ github, context, core }, body, number, sender)
|
return identify({ github, context, core }, number)
|
||||||
|
|
||||||
- name: Fetch Docker image
|
- name: Fetch Docker image
|
||||||
if: (env.TEST_CONTINUE)
|
if: (env.TEST_CONTINUE)
|
||||||
|
|||||||
@@ -2,15 +2,7 @@ const noFound = 'Auto: Route No Found';
|
|||||||
const testFailed = 'Auto: Route Test Failed';
|
const testFailed = 'Auto: Route Test Failed';
|
||||||
const allowedUser = new Set(['dependabot[bot]', 'pull[bot]']); // dependabot and downstream PR requested by pull[bot]
|
const allowedUser = new Set(['dependabot[bot]', 'pull[bot]']); // dependabot and downstream PR requested by pull[bot]
|
||||||
|
|
||||||
export default async function identify({ github, context, core }, body, number, sender) {
|
export default async function identify({ github, context, core }, number) {
|
||||||
core.debug(`sender: ${sender}`);
|
|
||||||
core.debug(`body: ${body}`);
|
|
||||||
// Remove all HTML comments before performing the match
|
|
||||||
const bodyNoCmts = body?.replaceAll(/<!--[\S\s]*?-->/g, '');
|
|
||||||
const m = bodyNoCmts?.match(/```routes\s+([\S\s]*?)```/);
|
|
||||||
core.debug(`match: ${m}`);
|
|
||||||
let routes = null;
|
|
||||||
|
|
||||||
const issueFacts = {
|
const issueFacts = {
|
||||||
owner: context.repo.owner,
|
owner: context.repo.owner,
|
||||||
repo: context.repo.repo,
|
repo: context.repo.repo,
|
||||||
@@ -21,6 +13,22 @@ export default async function identify({ github, context, core }, body, number,
|
|||||||
repo: context.repo.repo,
|
repo: context.repo.repo,
|
||||||
pull_number: number,
|
pull_number: number,
|
||||||
};
|
};
|
||||||
|
const { data: pr } = await github.rest.issues
|
||||||
|
.get({
|
||||||
|
...issueFacts,
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
core.warning(error);
|
||||||
|
});
|
||||||
|
const sender = pr.user.login;
|
||||||
|
const body = pr.body;
|
||||||
|
core.debug(`sender: ${sender}`);
|
||||||
|
core.debug(`body: ${body}`);
|
||||||
|
// Remove all HTML comments before performing the match
|
||||||
|
const bodyNoCmts = body?.replaceAll(/<!--[\S\s]*?-->/g, '');
|
||||||
|
const m = bodyNoCmts?.match(/```routes\s+([\S\s]*?)```/);
|
||||||
|
core.debug(`match: ${m}`);
|
||||||
|
let routes = null;
|
||||||
|
|
||||||
const addLabels = (labels) =>
|
const addLabels = (labels) =>
|
||||||
github.rest.issues
|
github.rest.issues
|
||||||
@@ -31,7 +39,6 @@ export default async function identify({ github, context, core }, body, number,
|
|||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
core.warning(error);
|
core.warning(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
const removeLabel = (labelName = noFound) =>
|
const removeLabel = (labelName = noFound) =>
|
||||||
github.rest.issues
|
github.rest.issues
|
||||||
.removeLabel({
|
.removeLabel({
|
||||||
@@ -41,7 +48,6 @@ export default async function identify({ github, context, core }, body, number,
|
|||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
core.warning(error);
|
core.warning(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
const updatePrState = (state) =>
|
const updatePrState = (state) =>
|
||||||
github.rest.pulls
|
github.rest.pulls
|
||||||
.update({
|
.update({
|
||||||
@@ -51,7 +57,6 @@ export default async function identify({ github, context, core }, body, number,
|
|||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
core.warning(error);
|
core.warning(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
const createComment = (body) =>
|
const createComment = (body) =>
|
||||||
github.rest.issues
|
github.rest.issues
|
||||||
.createComment({
|
.createComment({
|
||||||
@@ -61,7 +66,6 @@ export default async function identify({ github, context, core }, body, number,
|
|||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
core.warning(error);
|
core.warning(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
const createFailedComment = () => {
|
const createFailedComment = () => {
|
||||||
const logUrl = `${process.env.GITHUB_SERVER_URL}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
|
const logUrl = `${process.env.GITHUB_SERVER_URL}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
|
||||||
|
|
||||||
@@ -74,13 +78,6 @@ export default async function identify({ github, context, core }, body, number,
|
|||||||
路由测试失败,请确认评论部分符合格式规范,详情请检查 [日志](${logUrl})。`);
|
路由测试失败,请确认评论部分符合格式规范,详情请检查 [日志](${logUrl})。`);
|
||||||
};
|
};
|
||||||
|
|
||||||
const pr = await github.rest.issues
|
|
||||||
.get({
|
|
||||||
...issueFacts,
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
core.warning(error);
|
|
||||||
});
|
|
||||||
if (pr.pull_request) {
|
if (pr.pull_request) {
|
||||||
if (pr.state === 'closed') {
|
if (pr.state === 'closed') {
|
||||||
await updatePrState('open');
|
await updatePrState('open');
|
||||||
|
|||||||
Reference in New Issue
Block a user