Repository navigation
52 lines (48 loc) · 1.65 KB
/
Copy pathbranch-flow.yml
File metadata and controls
52 lines (48 loc) · 1.65 KB
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
50
51
52
name: Branch flow
# Changes flow one way: topic branches → develop → qa → main, and main is what's published.
# Urgent fixes go hotfix/* → main and are merged back. This check fails a pull request aimed at
# the wrong branch.
on:
pull_request:
types: [opened, reopened, edited, synchronize]
permissions:
contents: read
jobs:
direction:
name: Branch flow
runs-on: ubuntu-24.04
steps:
- name: Check the source and target branches
env:
FROM: ${{ github.head_ref }}
TO: ${{ github.base_ref }}
FROM_FORK: ${{ github.event.pull_request.head.repo.full_name != github.repository }}
run: |
refuse() {
echo "::error::A pull request from '$FROM' can't target '$TO'. $1"
exit 1
}
case "$TO" in
develop)
[ "$FROM_FORK" = "true" ] && exit 0
case "$FROM" in
feature/* | fix/* | chore/* | docs/* | content/* | dependabot/* | main) exit 0 ;;
*) refuse "Name the branch feature/…, fix/…, chore/…, docs/… or content/…." ;;
esac
;;
qa)
case "$FROM" in
develop | main) exit 0 ;;
*) refuse "Only develop is promoted to qa (and main, to bring back a hotfix)." ;;
esac
;;
main)
case "$FROM" in
qa | hotfix/*) exit 0 ;;
*) refuse "Only qa and hotfix/* branches go into main." ;;
esac
;;
*)
refuse "Open pull requests against develop."
;;
esac