File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Branch Name Check
2+
3+ on :
4+ pull_request :
5+ types : [opened, synchronize, reopened]
6+
7+ jobs :
8+ check_branch_name :
9+ runs-on : Linux # Use the default GitHub-hosted runner with Linux
10+
11+ steps :
12+ - name : Check out code
13+ uses : actions/checkout@v2
14+
15+ - name : Check branch name using Bash
16+ env :
17+ BRANCH_NAME : ${{ github.event.pull_request.head.ref }}
18+ USER : ${{ github.actor }}
19+ run : |
20+ echo "Original USER: $USER"
21+ BASE_USER=${USER%_amdeng} # Trim the trailing _amdeng from the USER
22+ echo "Trimmed USER: $BASE_USER"
23+
24+ echo "Checking branch name: $BRANCH_NAME"
25+ if [[ ! "$BRANCH_NAME" =~ ^u/.*/PR/.*$ ]] && [[ ! "$BRANCH_NAME" =~ ^u/.*/WIP/.*$ ]]; then
26+ echo "Error: Branch name '$BRANCH_NAME' does not match the required naming convention 'u/$BASE_USER/PR-*' or 'u/$BASE_USER/WIP-*'."
27+ exit 1
28+ fi
29+ echo "Branch name '$BRANCH_NAME' is valid."
30+ shell : bash # Use the default Linux shell
You can’t perform that action at this time.
0 commit comments