DLP: Added version API #5
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Branch Name Check | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| jobs: | |
| check_branch_name: | |
| runs-on: Linux # Using your self-hosted runner labeled 'Linux' | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v2 | |
| - name: Check branch name using Bash | |
| env: | |
| BRANCH_NAME: ${{ github.event.pull_request.head.ref }} | |
| USER: ${{ github.actor }} | |
| run: | | |
| echo "Original USER: $USER" | |
| BASE_USER=${USER%_amdeng} # Trim the trailing _amdeng from the USER | |
| echo "Trimmed USER: $BASE_USER" | |
| echo "Checking branch name: $BRANCH_NAME" | |
| # Use case-insensitive regex by converting branch name to lowercase | |
| LOWER_BRANCH_NAME=$(echo "$BRANCH_NAME" | tr '[:upper:]' '[:lower:]') | |
| LOWER_BASE_USER=$(echo "$BASE_USER" | tr '[:upper:]' '[:lower:]') | |
| PR_PATTERN="^u/${LOWER_BASE_USER}/pr/" | |
| WIP_PATTERN="^u/${LOWER_BASE_USER}/wip/" | |
| if [[ "${LOWER_BRANCH_NAME}" =~ $PR_PATTERN ]]; then | |
| echo "Branch name '$BRANCH_NAME' is recognized as a PR branch." | |
| elif [[ "${LOWER_BRANCH_NAME}" =~ $WIP_PATTERN ]]; then | |
| echo "Branch name '$BRANCH_NAME' is recognized as a WIP branch." | |
| else | |
| echo "Error: Branch name '$BRANCH_NAME' does not match the required naming conventions 'u/$BASE_USER/pr/*' or 'u/$BASE_USER/wip/*'. Examples of acceptable formats include 'u/$BASE_USER/PR/*', 'u/$BASE_USER/pr/*', 'u/$BASE_USER/WIP/*', or 'u/$BASE_USER/wip/*' (case-insensitive)." | |
| exit 1 | |
| fi | |
| shell: bash |