-
Notifications
You must be signed in to change notification settings - Fork 1
76 lines (70 loc) · 2.63 KB
/
determine-e2e-branch.yml
File metadata and controls
76 lines (70 loc) · 2.63 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Determine E2E branch
on:
workflow_call:
inputs:
app_branch:
description: "Branch name from the app repo"
required: true
type: string
e2e_branch_input:
description: "Input override (main | default-feature-branch | custom)"
required: false
default: "default-feature-branch"
type: string
outputs:
branch:
description: "Resolved E2E branch"
value: ${{ jobs.determine.outputs.branch }}
jobs:
determine:
name: determine
runs-on: ubuntu-latest
outputs:
branch: ${{ steps.detect.outputs.branch }}
steps:
- name: Detect branch to use
id: detect
shell: bash
run: |
APP_BRANCH="${{ inputs.app_branch }}"
INPUT_BRANCH="${{ inputs.e2e_branch_input }}"
TEST_REPO="synonymdev/bitkit-e2e-tests"
CALLER_REPO="${{ github.repository }}"
# Platform-specific base branch overrides.
# When a platform needs a different base than 'main', update it here.
# Set both back to 'main' once platforms are aligned again.
declare -A BASE_OVERRIDES=(
["ios"]="main"
["android"]="main"
)
PLATFORM=""
if [[ "$CALLER_REPO" == */bitkit-ios ]]; then
PLATFORM="ios"
elif [[ "$CALLER_REPO" == */bitkit-android ]]; then
PLATFORM="android"
fi
BASE_BRANCH="${BASE_OVERRIDES[$PLATFORM]:-main}"
echo "🧭 App branch: $APP_BRANCH"
echo "🧭 Input branch: $INPUT_BRANCH"
echo "🧭 Caller repo: $CALLER_REPO (platform: ${PLATFORM:-unknown})"
echo "🧭 Base branch: $BASE_BRANCH"
echo "🧭 Checking repo: $TEST_REPO"
if [[ "$INPUT_BRANCH" == "main" ]]; then
BRANCH="main"
elif [[ "$INPUT_BRANCH" == "default-feature-branch" ]]; then
if git ls-remote --exit-code https://github.com/$TEST_REPO.git "refs/heads/$APP_BRANCH" >/dev/null 2>&1; then
BRANCH="$APP_BRANCH"
echo "✅ Found matching branch: $BRANCH"
else
BRANCH="$BASE_BRANCH"
echo "⚠️ No '$APP_BRANCH' branch in $TEST_REPO, using '$BASE_BRANCH'."
fi
else
if git ls-remote --exit-code https://github.com/$TEST_REPO.git "refs/heads/$INPUT_BRANCH" >/dev/null 2>&1; then
BRANCH="$INPUT_BRANCH"
else
echo "::error title=Invalid e2e_branch::Branch '$INPUT_BRANCH' not found in $TEST_REPO"
exit 1
fi
fi
echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"