Skip to content

Commit

Permalink
Update action.yml and README.md
Browse files Browse the repository at this point in the history
Update disable-branch to disable-branches in index.ts
  • Loading branch information
NMZ0429 committed Jan 29, 2024
1 parent 9a90cb2 commit fe604f8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ jobs:
runs-on: ubuntu-latest
permissions: write-all # required to post a warning
steps:
- uses: NMZ0429/diff_CI@v1.3
- uses: NMZ0429/diff_CI@v1.5
with:
good-num-lines: 200 # optional: default is 300
max-num-lines: 400 # optional: default is 500
ignore: '["**/*.d.ts", "**/*.jpg"]' # optional: default is '[]'
disable-branch: "main" # optional: default is ""
disable-branches: '["develop", "main"]' # optional: default is ""
github-token: ${{ secrets.GITHUB_TOKEN }}
```
Expand Down
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ inputs:
description: "Files to ignore (gitignore format)"
required: false
default: "[]"
disable-branch:
disable-branches:
description: "If the PR is towards the specified branch, disable the action"
required: false
default: ""
default: "[]"
outputs:
num-diff-lines:
description: "The number of different lines in a PR"
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

16 changes: 9 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const token = getInput("github-token");
const goodNumLines = +getInput("good-num-lines");
const maxNumLines = +getInput("max-num-lines");
const ignorePatterns = JSON.parse(getInput("ignore"));
const disableBranch = getInput("disable-branch");
const disableBranch = JSON.parse(getInput("disable-branches"));

const octokit = new Octokit({ auth: `token ${token}` });
const getBaseBranch = async (
Expand All @@ -32,13 +32,15 @@ const getBaseBranch = async (
return data.base.ref;
};

if (disableBranch) {
if (disableBranch.length > 0) {
const baseBranch = await getBaseBranch(owner, repo, +pull_number);
if (baseBranch === disableBranch) {
notice(
`${owner}/${repo}#${pull_number} is targeting ${disableBranch}, skipping`
);
process.exit(0);
for (const branch of disableBranch) {
if (baseBranch === branch) {
notice(
`${owner}/${repo}#${pull_number} is targeting ${branch}, skipping`
);
process.exit(0);
}
}
}

Expand Down

0 comments on commit fe604f8

Please sign in to comment.