-
Notifications
You must be signed in to change notification settings - Fork 27
49 lines (44 loc) · 1.79 KB
/
comment_wrong_branch.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
name: Wrong Branch Warning
on:
workflow_dispatch:
pull_request:
types: [opened]
branches:
- "main"
jobs:
comment_warning:
if: ${{ github.event.pull_request.base.repo.clone_url != github.event.pull_request.head.repo.clone_url }}
runs-on: ubuntu-latest
steps:
- name: Comment warning about the wrong branch selected for PR
id: comment_docker_image
uses: actions/github-script@v6
with:
script: |
const output = `
Warning: we only accept PRs to the \`dev\` branch. It looks like you've created a PR to the \`main\` branch. Please edit this PR and select the \`dev\` branch as the target branch instead. If this was intentional please ignore this message.
`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})
comment_warning_internal_pr:
if: ${{ github.event.pull_request.head.ref != 'dev' }}
runs-on: ubuntu-latest
steps:
- name: Comment warning about the wrong branch selected for PR
id: comment_docker_image
uses: actions/github-script@v6
with:
script: |
const output = `
Warning: we only accept PRs to main from the \`dev\` branch. It looks like you've created a PR from a different branch. Please edit this PR and select the \`dev\` branch as the source branch instead. If this was intentional please ignore this message.
`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})