-
-
Notifications
You must be signed in to change notification settings - Fork 6
55 lines (41 loc) · 1.4 KB
/
feature-branch-status-check.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
50
51
52
53
54
name: ✅Feature Branch Status Check
defaults:
run:
shell: pwsh
on:
pull_request_target:
branches: main
jobs:
feature_branch_status_check:
name: Feature Branch Status Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Validate Branch
run: |
$renovateRegEx = "^renovate/.+$";
$regex = '${{ vars.FEATURE_BRANCH_REGEX }}';
$headBranch = "${{ github.head_ref }}";
$baseBranch = "main";
$headBranchInvalid = $false;
$baseBranchInvalid = $false;
# If the PR branch is a Renovate branch, it is valid and do not check for a feature branch.
if ($headBranch -match $renovateRegEx) {
Write-Host "::notice::The head branch '$headBranch' is a Renovate branch.";
exit 0;
}
if ($headBranch -match $regex) {
Write-Host "::notice::The head branch '$headBranch' is valid.";
} else {
Write-Host "::error::The head branch '$headBranch' is invalid.";
$headBranchInvalid = $true;
}
if ($baseBranch -eq "main") {
Write-Host "::notice::The base branch '$baseBranch' is valid.";
} else {
Write-Host "::error::The base branch '$baseBranch' is invalid.";
$baseBranchInvalid = $true;
}
if ($headBranchInvalid -or $baseBranchInvalid) {
exit 1;
}