feat: merge-train/spartan (#23817) #12365
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: Merge-Train Create PR | |
| on: | |
| push: | |
| branches: | |
| - 'merge-train/*' | |
| jobs: | |
| create-pr: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check if PR exists and create if needed | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }} | |
| run: | | |
| branch="${{ github.ref_name }}" | |
| # Determine base branch. Most trains target next; the spartan-v5 | |
| # train targets the v5 release line (v5-next) instead. | |
| base_branch="next" | |
| if [[ "$branch" == "merge-train/spartan-v5" ]]; then | |
| base_branch="v5-next" | |
| fi | |
| # Skip if this is a merge commit (check for multiple parents) | |
| parent_count=$(git rev-list --parents -n 1 "${{ github.sha }}" | wc -w) | |
| if [[ $parent_count -gt 2 ]]; then | |
| echo "Skipping: This is a merge commit." | |
| exit 0 | |
| fi | |
| # Skip if this commit is already in the base branch | |
| if git merge-base --is-ancestor "${{ github.sha }}" "origin/$base_branch"; then | |
| echo "Skipping: This commit is already in the $base_branch branch" | |
| exit 0 | |
| fi | |
| # Check if PR already exists for this branch | |
| existing_pr=$(gh pr list --state open --head "$branch" --json number --jq '.[0].number // empty') | |
| if [[ -z "$existing_pr" ]]; then | |
| echo "No PR exists for $branch, creating one" | |
| # Create PR with ci-no-squash label | |
| labels="ci-no-squash" | |
| if [[ "$branch" == "merge-train/spartan" || "$branch" == "merge-train/spartan-v5" || "$branch" == "merge-train/ci" ]]; then | |
| labels="$labels,ci-full-no-test-cache" | |
| fi | |
| gh pr create --base "$base_branch" --head "$branch" \ | |
| --title "feat: $branch" \ | |
| --body "$(echo -e "See [merge-train-readme.md](https://github.com/${{ github.repository }}/blob/next/.github/workflows/merge-train-readme.md).\nThis is a merge-train.")" \ | |
| --label "$labels" | |
| echo "Created PR for $branch" | |
| else | |
| echo "PR #$existing_pr already exists for $branch" | |
| fi |