forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ci wait for label creation before exit (DIYgod#6655)
* fix: style and token used on exit * [CodeFactor] Apply fixes [ci skip] [skip ci] Co-authored-by: codefactor-io <support@codefactor.io>
- Loading branch information
1 parent
b09df0d
commit cb1506e
Showing
3 changed files
with
43 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,49 @@ | ||
const noFound = 'Auto: Route No Found'; | ||
|
||
module.exports = ({ github, context, core }, body, number) => { | ||
|
||
module.exports = async ({github, context, core}, body, number) => { | ||
core.debug(`body: ${body}`); | ||
const m = body.match(/```routes\r\n((.|\r\n)*)```/); | ||
core.debug(`match: ${m}`); | ||
let res = null; | ||
|
||
const removeLabel = () => { | ||
github.issues | ||
.removeLabel({ | ||
issue_number: number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
name: noFound, | ||
}) | ||
.catch((e) => { | ||
core.warning(e); | ||
}); | ||
}; | ||
const removeLabel = async () => github.issues.removeLabel({ | ||
issue_number: number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
name: noFound | ||
}).catch((e) => { core.warning(e); }); | ||
|
||
if (m && m[1]) { | ||
res = m[1].trim().split('\r\n'); | ||
res = m[1].trim().split("\r\n"); | ||
core.info(`routes detected: ${res}`); | ||
|
||
if (res.length > 0 && res[0] === 'NOROUTE') { | ||
core.info('PR stated no route, passing'); | ||
removeLabel(); | ||
github.issues | ||
.addLabels({ | ||
issue_number: number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
labels: ['Auto: No Route Needed'], | ||
}) | ||
.catch((e) => { | ||
core.warning(e); | ||
}); | ||
if (res.length > 0 && res[0] === "NOROUTE") { | ||
core.info("PR stated no route, passing"); | ||
await removeLabel(); | ||
await github.issues.addLabels({ | ||
issue_number: number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
labels: ['Auto: No Route Needed'] | ||
}).catch((e) => { core.warning(e); }); | ||
|
||
return; | ||
} else if (res.length > 0) { | ||
core.exportVariable('TEST_CONTINUE', true); | ||
removeLabel(); | ||
await removeLabel(); | ||
return res; | ||
} | ||
} | ||
|
||
core.info('seems no route found, failing'); | ||
core.info("seems no route found, failing"); | ||
|
||
github.issues.addLabels({ | ||
await github.issues.addLabels({ | ||
issue_number: number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
labels: [noFound], | ||
}); | ||
labels: [noFound] | ||
}).catch((e) => { core.warning(e); }); | ||
|
||
throw 'Please follow the PR rules: failed to detect route'; | ||
throw "Please follow the PR rules: failed to detect route"; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters