🔄 Update version to 0.0.1-alpha.202512271415.afe5b928 (alpha) #703
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: Auto PR Creation | |
| on: | |
| push: | |
| branches: | |
| - "dev/*" | |
| - "develop" | |
| - "test" | |
| - "ai/dev/*" | |
| - "ai/test/*" | |
| - "ai/checklist/*" | |
| jobs: | |
| pr-to-develop: | |
| name: Create/Update PR from dev/* → develop | |
| if: startsWith(github.ref, 'refs/heads/dev/') && !contains(github.event.head_commit.message, '🔄 Update version') && !contains(github.event.head_commit.message, '🤖 Update client APIs') && !contains(github.event.head_commit.message, 'proxy-smart-releaser') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check if PR already exists | |
| id: check-pr | |
| run: | | |
| PR_EXISTS=$(gh pr list --base develop --head ${{ github.ref_name }} --state open --json number --jq length) | |
| echo "pr_exists=$PR_EXISTS" >> $GITHUB_OUTPUT | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Check if develop branch exists | |
| id: check-branch | |
| run: | | |
| git fetch origin --prune | |
| if git ls-remote --heads origin develop | grep -q "refs/heads/develop"; then | |
| echo "Develop branch exists on remote" | |
| echo "needs_branch_creation=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "Develop branch doesn't exist → needs creation" | |
| echo "needs_branch_creation=true" >> $GITHUB_OUTPUT | |
| fi | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create develop branch if it doesn't exist | |
| if: steps.check-branch.outputs.needs_branch_creation == 'true' && steps.check-pr.outputs.pr_exists == '0' | |
| run: | | |
| # Try to create develop branch from main, fallback to current branch if main doesn't exist | |
| if git ls-remote --heads origin main | grep -q "refs/heads/main"; then | |
| git fetch origin main:main | |
| git checkout -b develop main | |
| echo "Created develop branch from main" | |
| else | |
| echo "Main branch doesn't exist, creating develop from current branch" | |
| git checkout -b develop | |
| fi | |
| git push origin develop | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Check if branches differ | |
| id: check-diff | |
| run: | | |
| # Now check for differences between current dev branch and develop (develop branch should exist now) | |
| # Switch back to the original dev branch first | |
| git checkout ${{ github.ref_name }} | |
| # Fetch develop branch without checking it out | |
| git fetch origin develop | |
| COMMITS_AHEAD=$(git rev-list --count origin/develop..HEAD) | |
| COMMITS_BEHIND=$(git rev-list --count HEAD..origin/develop) | |
| echo "commits_ahead=$COMMITS_AHEAD" >> $GITHUB_OUTPUT | |
| echo "commits_behind=$COMMITS_BEHIND" >> $GITHUB_OUTPUT | |
| echo "${{ github.ref_name }} is $COMMITS_AHEAD commits ahead and $COMMITS_BEHIND commits behind develop" | |
| if [ "$COMMITS_AHEAD" -gt 0 ]; then | |
| echo "has_changes=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "has_changes=false" >> $GITHUB_OUTPUT | |
| fi | |
| # Count TODOs in the codebase | |
| TODO_COUNT=$(grep -r " TODO:" \ | |
| --include="*.ts" --include="*.js" --include="*.tsx" --include="*.jsx" \ | |
| --include="*.vue" --include="*.py" --include="*.java" --include="*.cs" \ | |
| --include="*.go" --include="*.rs" --include="*.cpp" --include="*.c" \ | |
| --include="*.h" . | wc -l || echo "0") | |
| echo "todo_count=$TODO_COUNT" >> $GITHUB_OUTPUT | |
| echo "Found $TODO_COUNT TODOs in the codebase" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create Pull Request | |
| if: steps.check-pr.outputs.pr_exists == '0' && steps.check-diff.outputs.has_changes == 'true' | |
| run: | | |
| gh pr create \ | |
| --base develop \ | |
| --head ${{ github.ref_name }} \ | |
| --title "🔄 Auto-PR: Merge \`${{ github.ref_name }}\` → \`develop\`" \ | |
| --body "**Automated Pull Request** 🤖 | |
| This PR was automatically created to merge changes from \`${{ github.ref_name }}\` into \`develop\`. | |
| **Changes:** | |
| - Commits ahead of develop: ${{ steps.check-diff.outputs.commits_ahead }} | |
| - Commits behind develop: ${{ steps.check-diff.outputs.commits_behind }} | |
| - TODOs remaining in codebase: ${{ steps.check-diff.outputs.todo_count }} | |
| **Review:** Please review the changes before merging." | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Skip PR creation - no changes | |
| if: steps.check-pr.outputs.pr_exists == '0' && steps.check-diff.outputs.has_changes == 'false' | |
| run: | | |
| echo "⏭️ Skipping PR creation - no new commits in ${{ github.ref_name }} compared to develop" | |
| - name: Update existing PR | |
| if: steps.check-pr.outputs.pr_exists != '0' | |
| run: | | |
| echo "PR from ${{ github.ref_name }} to develop already exists. Updating with latest info..." | |
| # Get the PR number | |
| PR_NUMBER=$(gh pr list --base develop --head ${{ github.ref_name }} --state open --json number --jq '.[0].number') | |
| # Update PR body with current stats | |
| gh pr edit $PR_NUMBER --body "**Automated Pull Request** 🤖 | |
| This PR was automatically created to merge changes from \`${{ github.ref_name }}\` into \`develop\`. | |
| **Changes:** | |
| - Commits ahead of develop: ${{ steps.check-diff.outputs.commits_ahead }} | |
| - Commits behind develop: ${{ steps.check-diff.outputs.commits_behind }} | |
| - TODOs remaining in codebase: ${{ steps.check-diff.outputs.todo_count }} | |
| **Review:** Please review the changes before merging. | |
| _Last updated: $(date -u '+%Y-%m-%d %H:%M:%S UTC')_" | |
| echo "Updated PR #$PR_NUMBER with latest commit and TODO counts" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| pr-to-test: | |
| name: Create/Update PR from develop → test | |
| if: github.ref == 'refs/heads/develop' && !contains(github.event.head_commit.message, '🔄 Update version') && !contains(github.event.head_commit.message, '🤖 Update client APIs') && !contains(github.event.head_commit.message, 'proxy-smart-releaser') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check if PR already exists | |
| id: check-pr | |
| run: | | |
| PR_EXISTS=$(gh pr list --base test --head develop --state open --json number --jq length) | |
| echo "pr_exists=$PR_EXISTS" >> $GITHUB_OUTPUT | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Check if test branch exists | |
| id: check-branch | |
| run: | | |
| git fetch origin --prune | |
| if git ls-remote --heads origin test | grep -q "refs/heads/test"; then | |
| echo "Test branch exists on remote" | |
| echo "needs_branch_creation=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "Test branch doesn't exist → needs creation" | |
| echo "needs_branch_creation=true" >> $GITHUB_OUTPUT | |
| fi | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create test branch if it doesn't exist | |
| if: steps.check-branch.outputs.needs_branch_creation == 'true' && steps.check-pr.outputs.pr_exists == '0' | |
| run: | | |
| # Try to create test branch from main, fallback to develop if main doesn't exist | |
| if git ls-remote --heads origin main | grep -q "refs/heads/main"; then | |
| git fetch origin main:main | |
| git checkout -b test main | |
| echo "Created test branch from main" | |
| else | |
| echo "Main branch doesn't exist, creating test from develop" | |
| git checkout -b test develop | |
| fi | |
| git push origin test | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Check if branches differ | |
| id: check-diff | |
| run: | | |
| # Now check for differences between develop and test (test branch should exist now) | |
| # Switch back to develop branch first | |
| git checkout develop | |
| # Fetch test branch without checking it out | |
| git fetch origin test | |
| COMMITS_AHEAD=$(git rev-list --count origin/test..HEAD) | |
| COMMITS_BEHIND=$(git rev-list --count HEAD..origin/test) | |
| echo "commits_ahead=$COMMITS_AHEAD" >> $GITHUB_OUTPUT | |
| echo "commits_behind=$COMMITS_BEHIND" >> $GITHUB_OUTPUT | |
| echo "Develop is $COMMITS_AHEAD commits ahead and $COMMITS_BEHIND commits behind test" | |
| if [ "$COMMITS_AHEAD" -gt 0 ]; then | |
| echo "has_changes=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "has_changes=false" >> $GITHUB_OUTPUT | |
| fi | |
| # Count TODOs in the codebase | |
| TODO_COUNT=$(grep -r " TODO:" --include="*.ts" --include="*.js" --include="*.tsx" --include="*.jsx" --include="*.vue" --include="*.py" --include="*.java" --include="*.cs" --include="*.go" --include="*.rs" --include="*.cpp" --include="*.c" --include="*.h" . | wc -l || echo "0") | |
| echo "todo_count=$TODO_COUNT" >> $GITHUB_OUTPUT | |
| echo "Found $TODO_COUNT TODOs in the codebase" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create Pull Request | |
| if: steps.check-pr.outputs.pr_exists == '0' && steps.check-diff.outputs.has_changes == 'true' | |
| run: | | |
| gh pr create \ | |
| --base test \ | |
| --head develop \ | |
| --title "🧪 Auto-PR: Merge \`develop\` → \`test\`" \ | |
| --body "**Automated Pull Request** 🤖 | |
| Commits ahead of test: ${{ steps.check-diff.outputs.commits_ahead }} | |
| Commits behind test: ${{ steps.check-diff.outputs.commits_behind }} | |
| TODOs remaining in codebase: ${{ steps.check-diff.outputs.todo_count }}" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Skip PR creation – no changes | |
| if: steps.check-pr.outputs.pr_exists == '0' && steps.check-diff.outputs.has_changes == 'false' | |
| run: echo "⏭️ No new commits in develop compared to test" | |
| - name: Update existing PR | |
| if: steps.check-pr.outputs.pr_exists != '0' | |
| run: | | |
| echo "PR from develop to test already exists. Updating with latest info..." | |
| # Get the PR number | |
| PR_NUMBER=$(gh pr list --base test --head develop --state open --json number --jq '.[0].number') | |
| # Update PR body with current stats | |
| gh pr edit $PR_NUMBER --body "**Automated Pull Request** 🤖 | |
| Commits ahead of test: ${{ steps.check-diff.outputs.commits_ahead }} | |
| Commits behind test: ${{ steps.check-diff.outputs.commits_behind }} | |
| TODOs remaining in codebase: ${{ steps.check-diff.outputs.todo_count }} | |
| _Last updated: $(date -u '+%Y-%m-%d %H:%M:%S UTC')_" | |
| echo "Updated PR #$PR_NUMBER with latest commit and TODO counts" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| pr-to-main: | |
| name: Create/Update PR from test → main | |
| if: github.ref == 'refs/heads/test' && !contains(github.event.head_commit.message, '🔄 Update version') && !contains(github.event.head_commit.message, '🤖 Update client APIs') && !contains(github.event.head_commit.message, 'proxy-smart-releaser') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check if PR already exists | |
| id: check-pr | |
| run: | | |
| PR_EXISTS=$(gh pr list --base main --head test --state open --json number --jq length) | |
| echo "pr_exists=$PR_EXISTS" >> $GITHUB_OUTPUT | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Check if branches differ | |
| id: check-diff | |
| run: | | |
| # Fetch all branches to ensure we have the latest refs | |
| git fetch origin --prune | |
| # Check if main branch exists on remote | |
| if git ls-remote --heads origin main | grep -q "refs/heads/main"; then | |
| echo "Main branch exists on remote" | |
| git fetch origin main:main | |
| # Check if there are any commits between main and test | |
| COMMITS_AHEAD=$(git rev-list --count main..test) | |
| COMMITS_BEHIND=$(git rev-list --count test..main) | |
| echo "commits_ahead=$COMMITS_AHEAD" >> $GITHUB_OUTPUT | |
| echo "commits_behind=$COMMITS_BEHIND" >> $GITHUB_OUTPUT | |
| echo "Branch test is $COMMITS_AHEAD commits ahead and $COMMITS_BEHIND commits behind main" | |
| # Only create PR if we have commits to contribute | |
| if [ "$COMMITS_AHEAD" -gt 0 ]; then | |
| echo "has_changes=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "has_changes=false" >> $GITHUB_OUTPUT | |
| fi | |
| else | |
| echo "Main branch doesn't exist on remote, this will be the first PR to create main" | |
| echo "commits_ahead=1" >> $GITHUB_OUTPUT | |
| echo "commits_behind=0" >> $GITHUB_OUTPUT | |
| echo "has_changes=true" >> $GITHUB_OUTPUT | |
| fi | |
| # Count TODOs in the codebase | |
| TODO_COUNT=$(grep -r " TODO:" --include="*.ts" --include="*.js" --include="*.tsx" --include="*.jsx" --include="*.vue" --include="*.py" --include="*.java" --include="*.cs" --include="*.go" --include="*.rs" --include="*.cpp" --include="*.c" --include="*.h" . | wc -l || echo "0") | |
| echo "todo_count=$TODO_COUNT" >> $GITHUB_OUTPUT | |
| echo "Found $TODO_COUNT TODOs in the codebase" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create Pull Request | |
| if: steps.check-pr.outputs.pr_exists == '0' && steps.check-diff.outputs.has_changes == 'true' | |
| run: | | |
| gh pr create \ | |
| --base main \ | |
| --head test \ | |
| --title "🚀 Auto-PR: Merge \`test\` → \`main\`" \ | |
| --body "**Automated Pull Request** 🤖 | |
| This PR was automatically created to merge changes from \`test\` into \`main\`. | |
| **Changes:** | |
| - Commits ahead of main: ${{ steps.check-diff.outputs.commits_ahead }} | |
| - Commits behind main: ${{ steps.check-diff.outputs.commits_behind }} | |
| - TODOs remaining in codebase: ${{ steps.check-diff.outputs.todo_count }} | |
| **Review:** Please review the changes before merging." | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Skip PR creation - no changes | |
| if: steps.check-pr.outputs.pr_exists == '0' && steps.check-diff.outputs.has_changes == 'false' | |
| run: | | |
| echo "⏭️ Skipping PR creation - no new commits in test compared to main" | |
| - name: Update existing PR | |
| if: steps.check-pr.outputs.pr_exists != '0' | |
| run: | | |
| echo "PR from test to main already exists. Updating with latest info..." | |
| # Get the PR number | |
| PR_NUMBER=$(gh pr list --base main --head test --state open --json number --jq '.[0].number') | |
| # Update PR body with current stats | |
| gh pr edit $PR_NUMBER --body "**Automated Pull Request** 🤖 | |
| This PR was automatically created to merge changes from \`test\` into \`main\`. | |
| **Changes:** | |
| - Commits ahead of main: ${{ steps.check-diff.outputs.commits_ahead }} | |
| - Commits behind main: ${{ steps.check-diff.outputs.commits_behind }} | |
| - TODOs remaining in codebase: ${{ steps.check-diff.outputs.todo_count }} | |
| **Review:** Please review the changes before merging. | |
| _Last updated: $(date -u '+%Y-%m-%d %H:%M:%S UTC')_" | |
| echo "Updated PR #$PR_NUMBER with latest commit and TODO counts" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| ai-dev-to-ai-test: | |
| name: Create/Update PR from ai/dev/* → ai/test/* | |
| if: startsWith(github.ref, 'refs/heads/ai/dev/') && !contains(github.event.head_commit.message, '🔄 Update version') && !contains(github.event.head_commit.message, '🤖 Update client APIs') && !contains(github.event.head_commit.message, 'proxy-smart-releaser') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Extract branch name | |
| id: extract-branch | |
| run: | | |
| # Extract the branch name after ai/dev/ | |
| BRANCH_NAME=${{ github.ref_name }} | |
| TARGET_BRANCH="ai/test/${BRANCH_NAME#ai/dev/}" | |
| echo "target_branch=$TARGET_BRANCH" >> $GITHUB_OUTPUT | |
| echo "Target branch: $TARGET_BRANCH" | |
| - name: Check if PR already exists | |
| id: check-pr | |
| run: | | |
| PR_EXISTS=$(gh pr list --base ${{ steps.extract-branch.outputs.target_branch }} --head ${{ github.ref_name }} --state open --json number --jq length) | |
| echo "pr_exists=$PR_EXISTS" >> $GITHUB_OUTPUT | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Check if target branch exists | |
| id: check-branch | |
| run: | | |
| git fetch origin --prune | |
| if git ls-remote --heads origin ${{ steps.extract-branch.outputs.target_branch }} | grep -q "refs/heads/${{ steps.extract-branch.outputs.target_branch }}"; then | |
| echo "Target branch exists on remote" | |
| echo "needs_branch_creation=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "Target branch doesn't exist → needs creation" | |
| echo "needs_branch_creation=true" >> $GITHUB_OUTPUT | |
| fi | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create target branch if it doesn't exist | |
| if: steps.check-branch.outputs.needs_branch_creation == 'true' && steps.check-pr.outputs.pr_exists == '0' | |
| run: | | |
| # Create target ai/test branch from current ai/dev branch | |
| git checkout -b ${{ steps.extract-branch.outputs.target_branch }} | |
| git push origin ${{ steps.extract-branch.outputs.target_branch }} | |
| echo "Created ${{ steps.extract-branch.outputs.target_branch }} branch from current ai/dev branch" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Check if branches differ | |
| id: check-diff | |
| run: | | |
| git checkout ${{ github.ref_name }} | |
| git fetch origin ${{ steps.extract-branch.outputs.target_branch }} | |
| COMMITS_AHEAD=$(git rev-list --count origin/${{ steps.extract-branch.outputs.target_branch }}..HEAD) | |
| COMMITS_BEHIND=$(git rev-list --count HEAD..origin/${{ steps.extract-branch.outputs.target_branch }}) | |
| echo "commits_ahead=$COMMITS_AHEAD" >> $GITHUB_OUTPUT | |
| echo "commits_behind=$COMMITS_BEHIND" >> $GITHUB_OUTPUT | |
| echo "${{ github.ref_name }} is $COMMITS_AHEAD commits ahead and $COMMITS_BEHIND commits behind ${{ steps.extract-branch.outputs.target_branch }}" | |
| if [ "$COMMITS_AHEAD" -gt 0 ]; then | |
| echo "has_changes=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "has_changes=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create Pull Request | |
| if: steps.check-pr.outputs.pr_exists == '0' && steps.check-diff.outputs.has_changes == 'true' | |
| run: | | |
| gh pr create \ | |
| --base ${{ steps.extract-branch.outputs.target_branch }} \ | |
| --head ${{ github.ref_name }} \ | |
| --title "🤖 AI-PR: Merge \`${{ github.ref_name }}\` → \`${{ steps.extract-branch.outputs.target_branch }}\`" \ | |
| --body "**AI-Generated Pull Request** 🤖 | |
| This PR was automatically created to merge AI-enhanced changes from \`${{ github.ref_name }}\` into \`${{ steps.extract-branch.outputs.target_branch }}\`. | |
| **Changes:** | |
| - Commits ahead of target: ${{ steps.check-diff.outputs.commits_ahead }} | |
| - Commits behind target: ${{ steps.check-diff.outputs.commits_behind }} | |
| **Review:** AI-generated code - please review carefully before merging." | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Update existing PR | |
| if: steps.check-pr.outputs.pr_exists != '0' | |
| run: | | |
| PR_NUMBER=$(gh pr list --base ${{ steps.extract-branch.outputs.target_branch }} --head ${{ github.ref_name }} --state open --json number --jq '.[0].number') | |
| gh pr edit $PR_NUMBER --body "**AI-Generated Pull Request** 🤖 | |
| This PR was automatically created to merge AI-enhanced changes from \`${{ github.ref_name }}\` into \`${{ steps.extract-branch.outputs.target_branch }}\`. | |
| **Changes:** | |
| - Commits ahead of target: ${{ steps.check-diff.outputs.commits_ahead }} | |
| - Commits behind target: ${{ steps.check-diff.outputs.commits_behind }} | |
| **Review:** AI-generated code - please review carefully before merging. | |
| _Last updated: $(date -u '+%Y-%m-%d %H:%M:%S UTC')_" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| ai-test-to-dev: | |
| name: Create/Update PR from ai/test/* → dev/* | |
| if: startsWith(github.ref, 'refs/heads/ai/test/') && !contains(github.event.head_commit.message, '🔄 Update version') && !contains(github.event.head_commit.message, '🤖 Update client APIs') && !contains(github.event.head_commit.message, 'proxy-smart-releaser') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Extract branch name | |
| id: extract-branch | |
| run: | | |
| # Extract the branch name after ai/test/ | |
| BRANCH_NAME=${{ github.ref_name }} | |
| TARGET_BRANCH="dev/${BRANCH_NAME#ai/test/}" | |
| echo "target_branch=$TARGET_BRANCH" >> $GITHUB_OUTPUT | |
| echo "Target branch: $TARGET_BRANCH" | |
| - name: Check if PR already exists | |
| id: check-pr | |
| run: | | |
| PR_EXISTS=$(gh pr list --base ${{ steps.extract-branch.outputs.target_branch }} --head ${{ github.ref_name }} --state open --json number --jq length) | |
| echo "pr_exists=$PR_EXISTS" >> $GITHUB_OUTPUT | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Check if target branch exists | |
| id: check-branch | |
| run: | | |
| git fetch origin --prune | |
| if git ls-remote --heads origin ${{ steps.extract-branch.outputs.target_branch }} | grep -q "refs/heads/${{ steps.extract-branch.outputs.target_branch }}"; then | |
| echo "Target branch exists on remote" | |
| echo "needs_branch_creation=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "Target branch doesn't exist → needs creation" | |
| echo "needs_branch_creation=true" >> $GITHUB_OUTPUT | |
| fi | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create target branch if it doesn't exist | |
| if: steps.check-branch.outputs.needs_branch_creation == 'true' && steps.check-pr.outputs.pr_exists == '0' | |
| run: | | |
| # Create target dev branch from develop if it exists, otherwise from main | |
| if git ls-remote --heads origin develop | grep -q "refs/heads/develop"; then | |
| git fetch origin develop:develop | |
| git checkout -b ${{ steps.extract-branch.outputs.target_branch }} develop | |
| echo "Created ${{ steps.extract-branch.outputs.target_branch }} branch from develop" | |
| elif git ls-remote --heads origin main | grep -q "refs/heads/main"; then | |
| git fetch origin main:main | |
| git checkout -b ${{ steps.extract-branch.outputs.target_branch }} main | |
| echo "Created ${{ steps.extract-branch.outputs.target_branch }} branch from main" | |
| else | |
| echo "Neither develop nor main exists, creating from current branch" | |
| git checkout -b ${{ steps.extract-branch.outputs.target_branch }} | |
| fi | |
| git push origin ${{ steps.extract-branch.outputs.target_branch }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Check if branches differ | |
| id: check-diff | |
| run: | | |
| git checkout ${{ github.ref_name }} | |
| git fetch origin ${{ steps.extract-branch.outputs.target_branch }} | |
| COMMITS_AHEAD=$(git rev-list --count origin/${{ steps.extract-branch.outputs.target_branch }}..HEAD) | |
| COMMITS_BEHIND=$(git rev-list --count HEAD..origin/${{ steps.extract-branch.outputs.target_branch }}) | |
| echo "commits_ahead=$COMMITS_AHEAD" >> $GITHUB_OUTPUT | |
| echo "commits_behind=$COMMITS_BEHIND" >> $GITHUB_OUTPUT | |
| echo "${{ github.ref_name }} is $COMMITS_AHEAD commits ahead and $COMMITS_BEHIND commits behind ${{ steps.extract-branch.outputs.target_branch }}" | |
| if [ "$COMMITS_AHEAD" -gt 0 ]; then | |
| echo "has_changes=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "has_changes=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create Pull Request | |
| if: steps.check-pr.outputs.pr_exists == '0' && steps.check-diff.outputs.has_changes == 'true' | |
| run: | | |
| gh pr create \ | |
| --base ${{ steps.extract-branch.outputs.target_branch }} \ | |
| --head ${{ github.ref_name }} \ | |
| --title "🧪 AI-Test-PR: Merge \`${{ github.ref_name }}\` → \`${{ steps.extract-branch.outputs.target_branch }}\`" \ | |
| --body "**AI Test → Dev Pull Request** 🧪 | |
| This PR was automatically created to merge AI-generated test changes from \`${{ github.ref_name }}\` into \`${{ steps.extract-branch.outputs.target_branch }}\`. | |
| **Changes:** | |
| - Commits ahead of target: ${{ steps.check-diff.outputs.commits_ahead }} | |
| - Commits behind target: ${{ steps.check-diff.outputs.commits_behind }} | |
| **Review:** AI-generated tests and code - please review test coverage and implementation." | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Update existing PR | |
| if: steps.check-pr.outputs.pr_exists != '0' | |
| run: | | |
| PR_NUMBER=$(gh pr list --base ${{ steps.extract-branch.outputs.target_branch }} --head ${{ github.ref_name }} --state open --json number --jq '.[0].number') | |
| gh pr edit $PR_NUMBER --body "**AI Test → Dev Pull Request** 🧪 | |
| This PR was automatically created to merge AI-generated test changes from \`${{ github.ref_name }}\` into \`${{ steps.extract-branch.outputs.target_branch }}\`. | |
| **Changes:** | |
| - Commits ahead of target: ${{ steps.check-diff.outputs.commits_ahead }} | |
| - Commits behind target: ${{ steps.check-diff.outputs.commits_behind }} | |
| **Review:** AI-generated tests and code - please review test coverage and implementation. | |
| _Last updated: $(date -u '+%Y-%m-%d %H:%M:%S UTC')_" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| ai-checklist-to-ai-dev: | |
| name: Create/Update PR from ai/checklist/* → ai/dev/* | |
| if: startsWith(github.ref, 'refs/heads/ai/checklist/') && !contains(github.event.head_commit.message, '🔄 Update version') && !contains(github.event.head_commit.message, '🤖 Update client APIs') && !contains(github.event.head_commit.message, 'proxy-smart-releaser') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Extract branch name | |
| id: extract-branch | |
| run: | | |
| # Extract the branch name after ai/checklist/ | |
| BRANCH_NAME=${{ github.ref_name }} | |
| TARGET_BRANCH="ai/dev/${BRANCH_NAME#ai/checklist/}" | |
| echo "target_branch=$TARGET_BRANCH" >> $GITHUB_OUTPUT | |
| echo "Target branch: $TARGET_BRANCH" | |
| - name: Check if PR already exists | |
| id: check-pr | |
| run: | | |
| PR_EXISTS=$(gh pr list --base ${{ steps.extract-branch.outputs.target_branch }} --head ${{ github.ref_name }} --state open --json number --jq length) | |
| echo "pr_exists=$PR_EXISTS" >> $GITHUB_OUTPUT | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Check if target branch exists | |
| id: check-branch | |
| run: | | |
| git fetch origin --prune | |
| if git ls-remote --heads origin ${{ steps.extract-branch.outputs.target_branch }} | grep -q "refs/heads/${{ steps.extract-branch.outputs.target_branch }}"; then | |
| echo "Target branch exists on remote" | |
| echo "needs_branch_creation=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "Target branch doesn't exist → needs creation" | |
| echo "needs_branch_creation=true" >> $GITHUB_OUTPUT | |
| fi | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create target branch if it doesn't exist | |
| if: steps.check-branch.outputs.needs_branch_creation == 'true' && steps.check-pr.outputs.pr_exists == '0' | |
| run: | | |
| # Create target ai/dev branch from current ai/checklist branch | |
| git checkout -b ${{ steps.extract-branch.outputs.target_branch }} | |
| git push origin ${{ steps.extract-branch.outputs.target_branch }} | |
| echo "Created ${{ steps.extract-branch.outputs.target_branch }} branch from ${{ github.ref_name }}" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Check if branches differ | |
| id: check-diff | |
| run: | | |
| git checkout ${{ github.ref_name }} | |
| git fetch origin ${{ steps.extract-branch.outputs.target_branch }} | |
| COMMITS_AHEAD=$(git rev-list --count origin/${{ steps.extract-branch.outputs.target_branch }}..HEAD) | |
| COMMITS_BEHIND=$(git rev-list --count HEAD..origin/${{ steps.extract-branch.outputs.target_branch }}) | |
| echo "commits_ahead=$COMMITS_AHEAD" >> $GITHUB_OUTPUT | |
| echo "commits_behind=$COMMITS_BEHIND" >> $GITHUB_OUTPUT | |
| echo "${{ github.ref_name }} is $COMMITS_AHEAD commits ahead and $COMMITS_BEHIND commits behind ${{ steps.extract-branch.outputs.target_branch }}" | |
| if [ "$COMMITS_AHEAD" -gt 0 ]; then | |
| echo "has_changes=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "has_changes=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create Pull Request | |
| if: steps.check-pr.outputs.pr_exists == '0' && steps.check-diff.outputs.has_changes == 'true' | |
| run: | | |
| gh pr create \ | |
| --base ${{ steps.extract-branch.outputs.target_branch }} \ | |
| --head ${{ github.ref_name }} \ | |
| --title "✅ AI-Checklist-PR: Merge \`${{ github.ref_name }}\` → \`${{ steps.extract-branch.outputs.target_branch }}\`" \ | |
| --body "**AI Checklist → Test Pull Request** ✅ | |
| This PR was automatically created to merge AI-implemented checklist items from \`${{ github.ref_name }}\` into \`${{ steps.extract-branch.outputs.target_branch }}\`. | |
| **Changes:** | |
| - Commits ahead of target: ${{ steps.check-diff.outputs.commits_ahead }} | |
| - Commits behind target: ${{ steps.check-diff.outputs.commits_behind }} | |
| **Review:** AI-implemented checklist features - please review implementation and prepare for testing." | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Update existing PR | |
| if: steps.check-pr.outputs.pr_exists != '0' | |
| run: | | |
| PR_NUMBER=$(gh pr list --base ${{ steps.extract-branch.outputs.target_branch }} --head ${{ github.ref_name }} --state open --json number --jq '.[0].number') | |
| gh pr edit $PR_NUMBER --body "**AI Checklist → Test Pull Request** ✅ | |
| This PR was automatically created to merge AI-implemented checklist items from \`${{ github.ref_name }}\` into \`${{ steps.extract-branch.outputs.target_branch }}\`. | |
| **Changes:** | |
| - Commits ahead of target: ${{ steps.check-diff.outputs.commits_ahead }} | |
| - Commits behind target: ${{ steps.check-diff.outputs.commits_behind }} | |
| **Review:** AI-implemented checklist features - please review implementation and prepare for testing. | |
| _Last updated: $(date -u '+%Y-%m-%d %H:%M:%S UTC')_" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |