Skip to content

Commit

Permalink
feat: Automatically apply label for review + PR comment for draft PRs (
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkerkhove committed Jan 11, 2024
1 parent 237c1c0 commit f355663
Showing 1 changed file with 40 additions and 3 deletions.
43 changes: 40 additions & 3 deletions .github/workflows/pr-welcome.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ name: PR Welcome Bot

on:
pull_request_target:
types: [opened]
types: [opened, ready_for_review]
branches:
- 'main'
pull_request_review:
types: [submitted, edited]

permissions:
issues: write
Expand All @@ -15,8 +17,21 @@ jobs:
name: PR Bot
runs-on: ubuntu-latest
steps:
- name: 'Comment on PR'
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7
- name: 'Add welcome comment on PR (draft)'
uses: actions/github-script@v6
if: "github.event.pull_request.draft"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{ github.event.number }},
body: 'Thank you for your contribution! 🙏 Let us know when you are ready for a review by publishing the PR.'
});
- name: 'Add welcome comment on PR'
uses: actions/github-script@v6
if: "!github.event.pull_request.draft"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
Expand All @@ -26,3 +41,25 @@ jobs:
issue_number: ${{ github.event.number }},
body: 'Thank you for your contribution! 🙏 We will review your PR as soon as possible.\n\n\n While you are waiting, make sure to:\n\n\n- Add an entry in [our changelog](https://github.com/kedacore/keda/blob/main/CHANGELOG.md) in alphabetical order and link related issue\n- Update the [documentation](https://github.com/kedacore/keda-docs), if needed\n- Add unit & [e2e](https://github.com/kedacore/keda/blob/main/tests/README.md) tests for your changes\n- GitHub checks are passing\n- Is the DCO check failing? Here is [how you can fix DCO issues](https://github.com/kedacore/keda/blob/main/CONTRIBUTING.md#i-didnt-sign-my-commit-now-what)\n\n\nLearn more about:\n- Our [contribution guide](https://github.com/kedacore/keda/blob/main/CONTRIBUTING.md)'
});
- name: 'Apply review required label'
uses: actions/github-script@v6
if: "!github.event.pull_request.draft"
with:
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ["requires-pr-review"]
})
- name: 'Remove review required label'
uses: actions/github-script@v6
if: github.event_name == 'pull_request_review' && (github.event.review.state == 'submitted' || github.event.review.state == 'edited')
with:
script: |
github.rest.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: "requires-pr-review"
})

0 comments on commit f355663

Please sign in to comment.