49 lines
1.6 KiB
YAML
49 lines
1.6 KiB
YAML
name: PR Target Branch Check
|
|
|
|
on:
|
|
pull_request_target:
|
|
types: [opened, edited]
|
|
|
|
jobs:
|
|
check-target:
|
|
runs-on: ubuntu-latest
|
|
permissions: {}
|
|
# Skip develop→master PRs (maintainer releases)
|
|
if: >-
|
|
github.event.pull_request.base.ref == 'master' &&
|
|
github.event.pull_request.head.ref != 'develop'
|
|
steps:
|
|
- uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
|
|
id: app-token
|
|
with:
|
|
client-id: ${{ secrets.APP_CLIENT_ID }}
|
|
private-key: ${{ secrets.APP_PRIVATE_KEY }}
|
|
permission-pull-requests: write
|
|
|
|
- name: Add wrong-base label and comment
|
|
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
|
|
with:
|
|
github-token: ${{ steps.app-token.outputs.token }}
|
|
script: |
|
|
const pr = context.payload.pull_request;
|
|
|
|
// Add label
|
|
await github.rest.issues.addLabels({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: pr.number,
|
|
labels: ['wrong-base']
|
|
});
|
|
|
|
// Post comment
|
|
const body = `Automatic message from CI checks : It seems like this branch is targeting the wrong branch, any contribution should target develop branch.
|
|
|
|
See [CONTRIBUTING.md](https://github.com/rtk-ai/rtk/blob/master/CONTRIBUTING.md) for details.`;
|
|
|
|
await github.rest.issues.createComment({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: pr.number,
|
|
body: body
|
|
});
|