Fail CI on invalid config file

This commit is contained in:
Hani
2023-01-27 15:15:02 -05:00
parent fe23d65c8e
commit 8464c95d2f
4 changed files with 11 additions and 7 deletions
+4 -2
View File
@@ -30,10 +30,12 @@ Create a config file `.github/pr-title-checker-config.json` like this one below:
```
You can pass in one of `prefixes` or `regexp` or even both based on your use case. `regexpFlags` and `ignoreLables` are optional fields.
If `LABEL.name` is set to `""`, adding or removing labels will be skipped. The CI test will continue to pass/fail accordingly.
If none of the checks pass, a label will be added to that pull request. \
If at least one of them passes, the label will be removed.
This action causes CI tests to fail by default. However, if you don't want CI tests failing just because of this action, simply set `alwaysPassCI` as true in the CHECKS field.
This action causes CI tests to fail by default. However, if you do not want CI tests failing just because of this action, simply set `alwaysPassCI` as true in the CHECKS field. **An invalid config file will always cause the action to fail.**
Also, adding label names to the optional `ignoreLabels` field will forfeit any checks for PRs with those labels.
@@ -56,7 +58,7 @@ jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: thehanimo/[email protected].5
- uses: thehanimo/[email protected].6
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
pass_on_octokit_error: false
+3 -2
View File
@@ -62894,11 +62894,12 @@ async function run() {
let config;
try {
config = await getJSON(configPath);
config = JSON.parse(config);
} catch (e) {
_actions_core__WEBPACK_IMPORTED_MODULE_0__.setFailed(`Couldn't retrieve the config file specified - ${e}`);
_actions_core__WEBPACK_IMPORTED_MODULE_0__.setFailed(`Couldn't retrieve or parse the config file specified - ${e}`);
return;
}
let { CHECKS, LABEL, MESSAGES } = JSON.parse(config);
let { CHECKS, LABEL, MESSAGES } = config;
LABEL = LABEL || {};
LABEL.name = LABEL.name || "";
LABEL.color = LABEL.color || "eee";
+1 -1
View File
File diff suppressed because one or more lines are too long
+3 -2
View File
@@ -17,11 +17,12 @@ async function run() {
let config;
try {
config = await getJSON(configPath);
config = JSON.parse(config);
} catch (e) {
core.setFailed(`Couldn't retrieve the config file specified - ${e}`);
core.setFailed(`Couldn't retrieve or parse the config file specified - ${e}`);
return;
}
let { CHECKS, LABEL, MESSAGES } = JSON.parse(config);
let { CHECKS, LABEL, MESSAGES } = config;
LABEL = LABEL || {};
LABEL.name = LABEL.name || "";
LABEL.color = LABEL.color || "eee";