CI Testing Upgrade #22339
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: Check PR Target Branch | |
| # Cancel older jobs on PRs when new changes are pushed | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened, edited] | |
| jobs: | |
| check-target-branch: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check if PR targets starlight-dev | |
| run: | | |
| SOURCE_BRANCH="${{ github.event.pull_request.head.ref }}" | |
| TARGET_BRANCH="${{ github.event.pull_request.base.ref }}" | |
| echo "PR from: $SOURCE_BRANCH -> $TARGET_BRANCH" | |
| # Allow starlight-dev to starlight PRs in both directions | |
| if [[ ("$SOURCE_BRANCH" == "starlight-dev" && "$TARGET_BRANCH" == "Starlight") || | |
| ("$SOURCE_BRANCH" == "Starlight" && "$TARGET_BRANCH" == "starlight-dev") ]]; then | |
| echo "Allowed: PR between starlight-dev and starlight branches" | |
| exit 0 | |
| fi | |
| # For all other PRs, require starlight-dev as target | |
| if [ "$TARGET_BRANCH" != "starlight-dev" ]; then | |
| echo "Error: PR must target 'starlight-dev' branch, but targets '$TARGET_BRANCH'" | |
| echo "Please change the target branch to 'starlight-dev'" | |
| exit 1 | |
| else | |
| echo "Success: PR correctly targets 'starlight-dev' branch" | |
| fi |