Skip to content

Commit

Permalink
ci: add new feature notifier (#2889)
Browse files Browse the repository at this point in the history
feat(ci): add new feature notifier

Signed-off-by: Janek Nouvertné <[email protected]>

---------

Signed-off-by: Janek Nouvertné <[email protected]>
Co-authored-by: Janek Nouvertné <[email protected]>
  • Loading branch information
JacobCoffee and provinzkraut authored Jan 7, 2024
1 parent 60c2fb3 commit 4480918
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions .github/workflows/pr-target.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,35 @@ on:
- opened
- edited
- synchronize
branches:
- main

permissions:
pull-requests: read
pull-requests: write

jobs:
main:
name: Validate PR target branch
runs-on: ubuntu-latest
steps:
- name: Check PR target
if: ${{ startsWith(github.event.pull_request.title, 'feat') }}
id: check-pr-target
uses: actions/github-script@v7
with:
script: |
const isFeature = context.payload.pull_request.title.startsWith('feat');
const targetsMain = context.payload.pull_request.base.ref == 'main';
core.setOutput('needs-rebase', isFeature && targetsMain ? 'true' : 'false');
- name: Comment PR
if: steps.check-pr-target.outputs.needs-rebase == 'true'
uses: thollander/actions-comment-pull-request@v2
with:
message: "It looks like you are adding a new feature! :rocket: Please rebase and point your PR to the `develop` branch."
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
comment_tag: check_pr_target
mode: recreate

- name: Fail if feature PR is targeted to main
if: steps.check-pr-target.outputs.needs-rebase == 'true'
uses: actions/github-script@v7
with:
script: |
Expand Down

0 comments on commit 4480918

Please sign in to comment.