1
1
name : Check unallowed file changes
2
2
3
3
on :
4
- push :
4
+ pull_request :
5
+ paths :
6
+ - ' .github/workflows/**'
7
+ - ' .github/CODEOWNERS'
8
+ - ' translations/**'
9
+ - ' assets/fonts/**'
10
+ - ' data/graphql/**'
11
+ - ' lib/graphql/**'
12
+ - ' lib/redirects/**'
13
+ - ' lib/rest/**'
14
+ - ' lib/webhooks/**'
5
15
6
16
jobs :
7
17
triage :
8
- if : github.repository == 'github/docs' && github.event.pull_request.pull_request. user.login != 'Octomerger'
18
+ if : github.repository == 'github/docs' && github.event.pull_request.user.login != 'Octomerger'
9
19
runs-on : ubuntu-latest
10
20
steps :
11
21
- uses : actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
12
- - name : Get pull request number
13
- id : pull-number
14
- uses : actions/github-script@626af12fe9a53dc2972b48385e7fe7dec79145c9
15
- with :
16
- github-token : ${{secrets.GITHUB_TOKEN}}
17
- result-encoding : string
18
- script : |
19
- const pulls = await github.repos.listPullRequestsAssociatedWithCommit({
20
- ...context.repo,
21
- commit_sha: context.sha
22
- })
23
-
24
- return pulls.data.map(pull => pull.number).shift()
25
22
- name : Check for existing requested changes
26
23
id : requested-change
27
24
uses : actions/github-script@626af12fe9a53dc2972b48385e7fe7dec79145c9
@@ -31,13 +28,19 @@ jobs:
31
28
script : |
32
29
const pullReviews = await github.pulls.listReviews({
33
30
...context.repo,
34
- pull_number: ${{steps.pull-number.outputs.result}}
31
+ pull_number: context.payload.number
35
32
})
36
33
37
- return pullReviews.data
34
+ const botReviews = pullReviews.data
38
35
.filter(review => review.user.login === 'github-actions[bot]')
39
36
.sort((a, b) => new Date(b.submitted_at) - new Date(a.submitted_at))
40
37
.shift()
38
+
39
+ if (botReviews) {
40
+ console.log(`Pull request reviews authored by the github-action bot: ${botReviews}`)
41
+ }
42
+ return botReviews
43
+
41
44
- name : Get files changed
42
45
uses : dorny/paths-filter@eb75a1edc117d3756a18ef89958ee59f9500ba58
43
46
id : filter
@@ -89,29 +92,31 @@ jobs:
89
92
if (translationFiles.length > 0) {
90
93
await github.issues.addLabels({
91
94
...context.repo,
92
- issue_number: ${{steps.pull-number.outputs.result}} ,
95
+ issue_number: context.payload.number ,
93
96
labels: ['localization']
94
97
})
95
98
reviewMessage += "\n\nIt looks like you've modified translated content. Unfortunately, we are not able to accept pull requests for translated content. Our translation process involves an integration with an external service at crowdin.com, where all translation activity happens. We hope to eventually open up the translation process to the open source community, but we're not there yet. See https://github.com/github/docs/blob/main/CONTRIBUTING.md#earth_asia-translations for more details."
96
99
}
97
100
98
101
await github.pulls.createReview({
99
102
...context.repo,
100
- pull_number: ${{steps.pull-number.outputs.result}} ,
103
+ pull_number: context.payload.number ,
101
104
body: reviewMessage,
102
105
event: 'REQUEST_CHANGES'
103
106
})
104
107
# When the most recent review was CHANGES_REQUESTED and the existing
105
108
# PR no longer contains unallowed changes, dismiss the previous review
106
109
- name : Dismiss pull request review
107
- if : ${{ steps.filter.outputs.notAllowed == 'false' && fromJson(steps.requested-change.outputs.result).state == 'CHANGES_REQUESTED' }}
110
+ # Check that unallowed files aren't modified and that a
111
+ # CHANGES_REQUESTED review already exists
112
+ if : ${{ steps.filter.outputs.notAllowed == 'false' && steps.requested-change.outputs.result && fromJson(steps.requested-change.outputs.result).state == 'CHANGES_REQUESTED' }}
108
113
uses : actions/github-script@626af12fe9a53dc2972b48385e7fe7dec79145c9
109
114
with :
110
115
github-token : ${{secrets.GITHUB_TOKEN}}
111
116
script : |
112
117
await github.pulls.dismissReview({
113
118
...context.repo,
114
- pull_number: ${{steps.pull-number.outputs.result}} ,
119
+ pull_number: context.payload.number ,
115
120
review_id: ${{fromJson(steps.requested-change.outputs.result).id}},
116
121
message: `✨Looks like you reverted all files we don't accept contributions for. 🙌 A member of the docs team will review your PR soon. 🚂`
117
122
})
0 commit comments