|
| 1 | +# |
| 2 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 3 | +# or more contributor license agreements. See the NOTICE file |
| 4 | +# distributed with this work for additional information |
| 5 | +# regarding copyright ownership. The ASF licenses this file |
| 6 | +# to you under the Apache License, Version 2.0 (the |
| 7 | +# "License"); you may not use this file except in compliance |
| 8 | +# with the License. You may obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Unless required by applicable law or agreed to in writing, |
| 13 | +# software distributed under the License is distributed on an |
| 14 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | +# KIND, either express or implied. See the License for the |
| 16 | +# specific language governing permissions and limitations |
| 17 | +# under the License. |
| 18 | +# |
| 19 | + |
| 20 | +name: Auto Comment |
| 21 | + |
| 22 | +on: |
| 23 | + issues: |
| 24 | + types: [opened] # 触发条件:当问题被创建时 |
| 25 | + pull_request: |
| 26 | + types: [opened] # 触发条件:当拉取请求被创建时 |
| 27 | + |
| 28 | +permissions: |
| 29 | + issues: write # 允许写入问题 |
| 30 | + pull-requests: write # 允许写入拉取请求 |
| 31 | + |
| 32 | +jobs: |
| 33 | + comment: |
| 34 | + runs-on: ubuntu-latest |
| 35 | + steps: |
| 36 | + - name: Comment on issue |
| 37 | + uses: actions/github-script@v4 |
| 38 | + with: |
| 39 | + script: | |
| 40 | + const issueOpened = "Thank you for raising an issue. We will try and get back to you as soon as possible. Please make sure you have given us as much context as possible."; |
| 41 | + const pullRequestOpened = "Thank you for raising your pull request. Please make sure you have followed our contributing guidelines. We will review it as soon as possible."; |
| 42 | +
|
| 43 | + if (context.payload.action === 'opened') { |
| 44 | + const issueComment = context.payload.issue ? issueOpened : pullRequestOpened; |
| 45 | + await github.issues.createComment({ |
| 46 | + ...context.repo, |
| 47 | + issue_number: context.payload.issue ? context.payload.issue.number : context.payload.pull_request.number, |
| 48 | + body: issueComment |
| 49 | + }); |
| 50 | + } |
0 commit comments