diff --git a/README.md b/README.md index 1adf73b..4c1437b 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,9 @@ these directives (case-insensitive): If it does, the job running this action will fail, thus preventing downstream jobs or steps from running. Otherwise, jobs will run as usual. +The directives above are the defaults, but they could be customized +using `SKIP_DIRECTIVES` (see example below). + Non-pull request event will not be affected. This is because we want the CI to run when a PR is merged even though its last commit has a directive to skip CI for that PR. @@ -37,6 +40,17 @@ jobs: with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Example to use custom directives. + check_skip_another: + name: Skip something else + runs-on: ubuntu-latest + steps: + - name: Some other thing depends on this check (not shown) + uses: pllim/action-skip-ci@main + with: + SKIP_DIRECTIVES: '[skip other],[other skip]' + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # This is placeholder for your real tests. tests: name: Run tests diff --git a/action.yml b/action.yml index 49d4f57..1d145f6 100644 --- a/action.yml +++ b/action.yml @@ -2,6 +2,10 @@ name: 'Check skip CI' description: 'Fails job if commit message wants to skip CI.' author: 'pllim' inputs: + SKIP_DIRECTIVES: + description: 'Comma separated terms to skip CI' + default: '[skip ci],[ci skip],[skip action],[action skip],[skip actions],[actions skip]' + required: false GITHUB_TOKEN: description: 'GitHub access token' required: true diff --git a/dist/index.js b/dist/index.js index a5ebbee..a23782b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -41,11 +41,8 @@ const github = __importStar(__webpack_require__(438)); function run() { return __awaiter(this, void 0, void 0, function* () { try { - const accepted_flags = [ - '[skip ci]', '[ci skip]', - '[skip action]', '[action skip]', - '[skip actions]', '[actions skip]' - ]; + const accepted_flags_input = core.getInput("SKIP_DIRECTIVES", { required: false }); + const accepted_flags = accepted_flags_input.split(","); const pr = github.context.payload.pull_request; if (!pr) { core.info("This action only runs for pull request, exiting with no-op"); @@ -64,7 +61,7 @@ function run() { core.info(` ${accepted_flags[i]}`); } if (accepted_flags.some(v => msg.includes(v))) { - core.setFailed(`"${commit.data.message}" contains directive to skip CI, failing this check`); + core.setFailed(`"${commit.data.message}" contains directive to skip, failing this check`); /* Instead of failing, can also try to cancel but the token needs write access, so we cannot implement this for OSS in reality. */ /* @@ -79,7 +76,7 @@ function run() { */ } else { - core.info(`No directive to skip CI found in "${commit.data.message}", moving on...`); + core.info(`No directive to skip found in "${commit.data.message}", moving on...`); } } catch (err) { diff --git a/src/main.ts b/src/main.ts index 632540f..878ffa9 100644 --- a/src/main.ts +++ b/src/main.ts @@ -3,10 +3,8 @@ import * as github from "@actions/github"; async function run() { try { - const accepted_flags:Array = [ - '[skip ci]', '[ci skip]', - '[skip action]', '[action skip]', - '[skip actions]', '[actions skip]']; + const accepted_flags_input = core.getInput("SKIP_DIRECTIVES", { required: false }); + const accepted_flags = accepted_flags_input.split(","); const pr = github.context.payload.pull_request; if (!pr) { @@ -29,7 +27,7 @@ async function run() { } if (accepted_flags.some(v => msg.includes(v))) { - core.setFailed(`"${commit.data.message}" contains directive to skip CI, failing this check`); + core.setFailed(`"${commit.data.message}" contains directive to skip, failing this check`); /* Instead of failing, can also try to cancel but the token needs write access, so we cannot implement this for OSS in reality. */ @@ -44,7 +42,7 @@ async function run() { }); */ } else { - core.info(`No directive to skip CI found in "${commit.data.message}", moving on...`); + core.info(`No directive to skip found in "${commit.data.message}", moving on...`); } } catch(err) { core.setFailed(`Action failed with error ${err}`);