Skip to content

Commit d76c8b0

Browse files
committed
Update worfklow
1 parent d2795d5 commit d76c8b0

1 file changed

Lines changed: 20 additions & 9 deletions

File tree

.github/workflows/check_required_files.yml

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,31 +51,42 @@ jobs:
5151
lfs: false
5252
timeout-minutes: 10
5353

54-
# Exit early if the review is not requested from the `stdlib-bot` user:
55-
- name: 'Exit early if review is not requested from stdlib-bot'
54+
# Check if the review is requested from the `stdlib-bot` user:
55+
- name: 'Check if review is requested from stdlib-bot'
56+
id: check-reviewers
5657
run: |
57-
if [[ "${{ github.event.review.requested_reviewer.login }}" != "stdlib-bot" ]]; then
58-
echo "Review not requested from stdlib-bot. Exiting early."
59-
exit 0
58+
# Get the list of reviewers:
59+
reviewers=$(jq -r '.pull_request.requested_reviewers | .[] | .login' "$GITHUB_EVENT_PATH")
60+
61+
# Check if the list of reviewers contains the `stdlib-bot` user:
62+
if [[ $reviewers == *"stdlib-bot"* ]]; then
63+
echo "::set-output name=is_stdlib_bot::true"
64+
else
65+
echo "::set-output name=is_stdlib_bot::false"
6066
fi
6167
6268
# Get list of changed files:
6369
- name: 'Get list of changed files'
70+
if: steps.check-reviewers.outputs.is_stdlib_bot == 'true'
6471
id: changed-files
6572
uses: tj-actions/changed-files@v32
6673
with:
6774
separator: ' '
75+
base_sha: ${{ github.event.pull_request.base.sha }}
76+
sha: ${{ github.event.pull_request.head.sha }}
6877

69-
# Check whether the pull request contains a new `README.md` file; if not, exit with a zero exit code:
78+
# Check whether the pull request contains a new `README.md` file; if not, exit with a non-zero exit code:
7079
- name: 'Exit if pull request does not contain a new README.md file'
80+
if: steps.check-reviewers.outputs.is_stdlib_bot == 'true'
7181
run: |
7282
if [[ ! "${{ steps.changed-files.outputs.added_files }}" =~ "README.md" ]]; then
7383
echo "Pull request does not contain a new README.md file."
74-
exit 0
84+
exit 1
7585
fi
7686
7787
# Check whether the pull request contains files which are required to be present for all packages:
7888
- name: 'Check whether the pull request contains files which are required to be present for all packages'
89+
if: steps.check-reviewers.outputs.is_stdlib_bot == 'true'
7990
id: check-required-files
8091
run: |
8192
# Define a list of required files:
@@ -91,8 +102,8 @@ jobs:
91102
"examples/index.js"
92103
"test/test.js"
93104
)
94-
# Get path of added `README.md` file:
95-
readme_path="${{ steps.changed-files.outputs.added_files }}" | grep "README.md"
105+
# Get path of first added `README.md` file:
106+
readme_path="${{ steps.changed-files.outputs.added_files }}" | tr ' ' '\n' | grep -E 'README.md$' | head -n 1
96107
97108
if grep -q '## CLI' "${readme_path}"; then
98109
required_files+=("bin/cli")

0 commit comments

Comments
 (0)