Skip to content

Commit 1b328f4

Browse files
authored
Merge pull request sap-linuxlab#1192 from berndfinger/new-workflow-for-checking-the-source-branch
workflow: New check to ensure that the main branch accepts only pull request from dev branch
2 parents 6f9dfd2 + 8f2cc61 commit 1b328f4

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Check PR branches
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- dev
8+
types:
9+
- opened
10+
- synchronize
11+
- reopened
12+
# Ensure re-check when branch is switched after PR is opened:
13+
- edited
14+
15+
jobs:
16+
check-pr-branches:
17+
runs-on: ubuntu-latest
18+
# Only run if it is not an edit OR if it is an edit to the base branch:
19+
if: github.event.action != 'edited' || github.event.changes.base.ref.from != null
20+
steps:
21+
- name: Check if PR to main is from dev branch
22+
if: github.base_ref == 'main' && github.head_ref != 'dev'
23+
run: |
24+
echo "PRs to the main branch are only allowed from the dev branch!"
25+
exit 1

0 commit comments

Comments
 (0)