Skip to content

Commit

Permalink
Responding to feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
zlayaAvocado committed Dec 24, 2024
1 parent 3fa0fb6 commit 3835dc1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
11 changes: 10 additions & 1 deletion .github/actions/require-multiple-reviewers-v1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ A GitHub Action that requires multiple reviewers for important files
```yaml
name: Require multiple reviewers

# This must be both pull_request and pull_request_review.
# pull_request - for when the PR is initially created (or files are changed)
# pull_request_review - for when the count of reviews on a PR changes
on:
pull_request:
pull_request_review:

jobs:
require-multiple-reviewers:
runs-on: ubuntu-latest
Expand All @@ -24,10 +31,12 @@ jobs:
contents: read
checks: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Require two reviewers for important files
uses: dequelabs/axe-api-team-public/.github/actions/require-multiple-reviewers-v1@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ github.token }}
number-of-reviewers: 2
important-files-path: .github/important-files.txt
```
Expand Down
7 changes: 3 additions & 4 deletions .github/actions/require-multiple-reviewers-v1/dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions .github/actions/require-multiple-reviewers-v1/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ export function getImportantFilesChanged(
IMPORTANT_FILES_PATH: string,
changedFiles: string[]
): string[] {
// Since this is the ignore package, it will filter out files that match the patterns
const notImportantFiles = ignore()
.add(fs.readFileSync(IMPORTANT_FILES_PATH, 'utf-8').toString())
.filter(changedFiles)
// Use the ignore package to create a filter for the important files.
const i = ignore().add(
fs.readFileSync(IMPORTANT_FILES_PATH, 'utf-8').toString()
)

// Get all the files that were filtered out earlier - those are the important files
return changedFiles.filter(file => !notImportantFiles.includes(file))
// Return the files that have changed and are important, since they will be "ignored" if this was a gitignore file.
return changedFiles.filter(file => i.ignores(file))
}

0 comments on commit 3835dc1

Please sign in to comment.