@@ -2,6 +2,8 @@ name: Check unallowed file changes
22
33on :
44 push :
5+ pull_request :
6+ types : [opened, reopened]
57
68jobs :
79 triage :
2022 ...context.repo,
2123 commit_sha: context.sha
2224 })
25+ const pullNumber = pulls.data
26+ .map(pull => pull.number)
27+ .shift()
2328
24- return pulls.data.map(pull => pull.number).shift()
29+ if (pullNumber) {
30+ console.log(`Pull request number: ${pullNumber}`)
31+ return pullNumber
32+ } else {
33+ console.log(`When this workflow ran, the associated pull request was not yet created. Pushing a new commit after you've created a pull request will automatically re-run this workflow, or you can manually re-run the workflow.`)
34+ process.exit(1)
35+ }
2536 - name : Check for existing requested changes
2637 id : requested-change
2738 uses : actions/github-script@626af12fe9a53dc2972b48385e7fe7dec79145c9
@@ -34,10 +45,16 @@ jobs:
3445 pull_number: ${{steps.pull-number.outputs.result}}
3546 })
3647
37- return pullReviews.data
48+ const botReviews = pullReviews.data
3849 .filter(review => review.user.login === 'github-actions[bot]')
3950 .sort((a, b) => new Date(b.submitted_at) - new Date(a.submitted_at))
4051 .shift()
52+
53+ if (botReviews) {
54+ console.log(`Pull request reviews authored by the github-action bot: ${botReviews}`)
55+ }
56+ return botReviews
57+
4158 - name : Get files changed
4259 uses : dorny/paths-filter@eb75a1edc117d3756a18ef89958ee59f9500ba58
4360 id : filter
@@ -104,7 +121,9 @@ jobs:
104121 # When the most recent review was CHANGES_REQUESTED and the existing
105122 # PR no longer contains unallowed changes, dismiss the previous review
106123 - name : Dismiss pull request review
107- if : ${{ steps.filter.outputs.notAllowed == 'false' && fromJson(steps.requested-change.outputs.result).state == 'CHANGES_REQUESTED' }}
124+ # Check that unallowed files aren't modified and that a
125+ # CHANGES_REQUESTED review already exists
126+ if : ${{ steps.filter.outputs.notAllowed == 'false' && steps.requested-change.outputs.result && fromJson(steps.requested-change.outputs.result).state == 'CHANGES_REQUESTED' }}
108127 uses : actions/github-script@626af12fe9a53dc2972b48385e7fe7dec79145c9
109128 with :
110129 github-token : ${{secrets.GITHUB_TOKEN}}
0 commit comments