Skip to content

Commit f1d746e

Browse files
PCSM. Change CI workflow to dynamically select branch in QA repo (#164)
1 parent b91b67b commit f1d746e

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

.github/workflows/ci.yml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,37 @@ jobs:
3737
env:
3838
PCSM_BRANCH: ${{ github.event_name == 'pull_request' && github.head_ref || github.event.inputs.pcsm_branch || 'main' }}
3939
steps:
40+
- name: Determine test branch
41+
id: test_branch
42+
run: |
43+
if [ -n "${{ github.event.inputs.tests_ver }}" ]; then
44+
echo "branch=${{ github.event.inputs.tests_ver }}" >> $GITHUB_OUTPUT
45+
elif [ -n "${{ github.event.pull_request.title }}" ]; then
46+
PR_TITLE="${{ github.event.pull_request.title }}"
47+
echo "PR title: $PR_TITLE"
48+
BRANCH_TO_CHECK=$(echo "$PR_TITLE" | grep -oE 'PCSM-[0-9]+' | head -1)
49+
if [ -n "$BRANCH_TO_CHECK" ]; then
50+
echo "Extracted branch pattern: $BRANCH_TO_CHECK"
51+
if curl -sf "https://api.github.com/repos/Percona-QA/psmdb-testing/branches/$BRANCH_TO_CHECK" > /dev/null; then
52+
echo "Branch $BRANCH_TO_CHECK found, using it"
53+
echo "branch=$BRANCH_TO_CHECK" >> $GITHUB_OUTPUT
54+
else
55+
echo "Branch $BRANCH_TO_CHECK not found, falling back to main"
56+
echo "branch=main" >> $GITHUB_OUTPUT
57+
fi
58+
else
59+
echo "No PCSM-XXXXX pattern found in PR title, using main"
60+
echo "branch=main" >> $GITHUB_OUTPUT
61+
fi
62+
else
63+
echo "branch=main" >> $GITHUB_OUTPUT
64+
fi
65+
4066
- name: Checkout testing repo
4167
uses: actions/checkout@v4
4268
with:
4369
repository: Percona-QA/psmdb-testing
44-
ref: ${{ github.event.inputs.tests_ver || 'main'}}
70+
ref: ${{ steps.test_branch.outputs.branch }}
4571
path: psmdb-testing
4672

4773
- name: Setup environment with PSMDB ${{ matrix.psmdb }} and PCSM PR/branch ${{ github.head_ref || github.event.inputs.pcsm_branch || env.PCSM_BRANCH }}

0 commit comments

Comments
 (0)