Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 28 additions & 9 deletions .github/workflows/kernel-build-and-test-multiarch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -343,13 +343,27 @@ jobs:
BASE_BRANCH="${{ github.base_ref }}"
echo "Using PR base branch: $BASE_BRANCH"
else
# Extract base branch from branch name pattern: {name}_base or {name}-base
# Match patterns like {shreeya}_ciqlts9_2 or {shreeya}-ciqlts9_2
if [[ "$BRANCH_NAME" =~ \{[^}]+\}[_-](.+) ]]; then
# Extract base branch from branch name.
# Two supported patterns (both require curly-brace {USER} prefix):
#
# 1. RLC pattern : {user}_rlc-N/VERSION
# e.g. {shreeya}_rlc-10/6.12.0-124.2.1.el10_1
# Base branch : rlc-N/VERSION (everything after the first '_')
# No whitelist validation — the version string is the base.
#
# 2. Legacy pattern: {user}_BASE or {user}-BASE
# e.g. {shreeya}_ciqlts9_2
# Base branch : BASE (must be in VALID_BASES whitelist)

if [[ "$BRANCH_NAME" =~ ^\{[^}]+\}_(rlc-[0-9]+/.+)$ ]]; then
# RLC pattern: base is rlc-N/VERSION
BASE_BRANCH="${BASH_REMATCH[1]}"
echo "Detected RLC branch pattern, base branch: $BASE_BRANCH"
elif [[ "$BRANCH_NAME" =~ \{[^}]+\}[_-](.+) ]]; then
# Legacy pattern: validate against whitelist
EXTRACTED_BASE="${BASH_REMATCH[1]}"
echo "Extracted base branch from branch name: $EXTRACTED_BASE"

# Validate against whitelist
if echo "$VALID_BASES" | grep -wq "$EXTRACTED_BASE"; then
BASE_BRANCH="$EXTRACTED_BASE"
echo "Base branch validated: $BASE_BRANCH"
Expand All @@ -359,8 +373,9 @@ jobs:
exit 1
fi
else
echo "::error::Branch name does not match expected pattern {name}_base or {name}-base"
echo "::error::Branch name must be in format {name}_base or {name}-base where base is one of: $VALID_BASES"
echo "::error::Branch name does not match any known pattern"
echo "::error:: Legacy pattern : {user}_BASE or {user}-BASE (BASE must be one of: $VALID_BASES)"
echo "::error:: RLC pattern : {user}_rlc-N/VERSION (e.g. {user}_rlc-10/6.12.0-124.2.1.el10_1)"
exit 1
fi
fi
Expand Down Expand Up @@ -409,9 +424,11 @@ jobs:
continue
fi

# Extract base from branch name pattern {name}_base or {name}-base
# Extract base from branch name — support both legacy and RLC patterns
EXTRACTED_BASE=""
if [[ "$HEAD_BRANCH" =~ \{[^}]+\}[_-](.+) ]]; then
if [[ "$HEAD_BRANCH" =~ ^\{[^}]+\}_(rlc-[0-9]+/.+)$ ]]; then
EXTRACTED_BASE="${BASH_REMATCH[1]}"
elif [[ "$HEAD_BRANCH" =~ \{[^}]+\}[_-](.+) ]]; then
EXTRACTED_BASE="${BASH_REMATCH[1]}"
fi

Expand Down Expand Up @@ -539,9 +556,11 @@ jobs:
if: success() || failure()

steps:
- name: Check if branch name contains curly brackets
- name: Check if branch name matches a supported pattern
run: |
BRANCH_NAME="${{ github.ref_name }}"
# Accept any branch whose name contains curly braces (covers both
# legacy {user}_BASE and RLC {user}_rlc-N/VERSION patterns)
if [[ ! "$BRANCH_NAME" =~ \{ ]] || [[ ! "$BRANCH_NAME" =~ \} ]]; then
echo "Branch name '$BRANCH_NAME' does not contain curly brackets, skipping PR creation"
exit 1
Expand Down
Loading