Skip to content

Commit 040e325

Browse files
authored
Merge pull request #9001 from github/repo-sync
repo sync
2 parents 29116c5 + 0b2ff2f commit 040e325

File tree

1 file changed

+20
-52
lines changed

1 file changed

+20
-52
lines changed

.github/workflows/triage-unallowed-contributions.yml

Lines changed: 20 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,6 @@ jobs:
2929
if: github.repository == 'github/docs' && github.event.pull_request.user.login != 'Octomerger'
3030
runs-on: ubuntu-latest
3131
steps:
32-
- name: Check for existing requested changes
33-
id: requested-change
34-
uses: actions/github-script@2b34a689ec86a68d8ab9478298f91d5401337b7d
35-
with:
36-
github-token: ${{secrets.GITHUB_TOKEN}}
37-
result-encoding: json
38-
script: |
39-
const pullReviews = await github.pulls.listReviews({
40-
...context.repo,
41-
pull_number: context.payload.number
42-
})
43-
44-
const botReviews = pullReviews.data
45-
.filter(review => review.user.login === 'github-actions[bot]')
46-
.sort((a, b) => new Date(b.submitted_at) - new Date(a.submitted_at))
47-
.shift()
48-
49-
if (botReviews) {
50-
console.log(`Pull request reviews authored by the github-action bot: ${botReviews}`)
51-
}
52-
return botReviews
53-
5432
- name: Get files changed
5533
uses: dorny/paths-filter@eb75a1edc117d3756a18ef89958ee59f9500ba58
5634
id: filter
@@ -86,11 +64,10 @@ jobs:
8664
- 'scripts/**'
8765
- 'translations/**'
8866
89-
# When there are changes to files we can't accept
90-
# and no review exists,leave a REQUEST_CHANGES review
91-
- name: Request pull request changes
92-
# Check for no reviews or reviews that aren't CHANGES_REQUESTED
93-
if: ${{ steps.filter.outputs.notAllowed == 'true' && (!steps.requested-change.outputs.result || fromJSON(steps.requested-change.outputs.result).state != 'CHANGES_REQUESTED') }}
67+
# When there are changes to files we can't accept, leave a comment
68+
# explaining this to the PR author
69+
- name: "Comment about changes we can't accept"
70+
if: ${{ steps.filter.outputs.notAllowed }}
9471
uses: actions/github-script@2b34a689ec86a68d8ab9478298f91d5401337b7d
9572
with:
9673
github-token: ${{secrets.GITHUB_TOKEN}}
@@ -109,36 +86,27 @@ jobs:
10986
'lib/webhooks/**',
11087
'lib/search/indexes/**',
11188
'package*.json',
112-
'Procfile'
89+
'Procfile',
11390
'scripts/**',
114-
'translations/**'
91+
'translations/**',
11592
]
11693
11794
const badFiles = badFilesArr.join('\n')
11895
11996
let reviewMessage = `👋 Hey there spelunker. It looks like you've modified some files that we can't accept as contributions. The complete list of files we can't accept are:\n${badFiles}\n\nYou'll need to revert all of the files you changed in that list using [GitHub Desktop](https://docs.github.com/en/free-pro-team@latest/desktop/contributing-and-collaborating-using-github-desktop/managing-commits/reverting-a-commit) or \`git checkout origin/main <file name>\`. Once you get those files reverted, we can continue with the review process. :octocat:`
97+
let workflowFailMessage = "It looks like you've modified some files that we can't accept as contributions."
12098
121-
await github.pulls.createReview({
122-
...context.repo,
123-
pull_number: context.payload.number,
124-
body: reviewMessage,
125-
event: 'REQUEST_CHANGES'
126-
})
99+
try {
100+
createdComment = await github.issues.createComment ({
101+
owner: context.repo.owner,
102+
repo: context.repo.repo,
103+
issue_number: context.payload.number,
104+
body: reviewMessage,
105+
})
127106
128-
core.setFailed("It looks like you've modified some files we don't accept contributions for. Please see the review with requested changes for details.")
129-
# When the most recent review was CHANGES_REQUESTED and the existing
130-
# PR no longer contains unallowed changes, dismiss the previous review
131-
- name: Dismiss pull request review
132-
# Check that unallowed files aren't modified and that a
133-
# CHANGES_REQUESTED review already exists
134-
if: ${{ steps.filter.outputs.notAllowed == 'false' && steps.requested-change.outputs.result && fromJSON(steps.requested-change.outputs.result).state == 'CHANGES_REQUESTED' }}
135-
uses: actions/github-script@2b34a689ec86a68d8ab9478298f91d5401337b7d
136-
with:
137-
github-token: ${{secrets.GITHUB_TOKEN}}
138-
script: |
139-
await github.pulls.dismissReview({
140-
...context.repo,
141-
pull_number: context.payload.number,
142-
review_id: ${{fromJSON(steps.requested-change.outputs.result).id}},
143-
message: `✨Looks like you reverted all files we don't accept contributions for. 🙌 A member of the docs team will review your PR soon. 🚂`
144-
})
107+
workflowFailMessage = `${workflowFailMessage} Please see ${createdComment.data.html_url} for details.`
108+
} catch(err) {
109+
console.log("Error creating comment.", err)
110+
}
111+
112+
core.setFailed(workflowFailMessage)

0 commit comments

Comments
 (0)