diff --git a/.github/workflows/docs-deploy.yaml b/.github/workflows/docs-deploy.yaml index d80f9092..519eaea8 100644 --- a/.github/workflows/docs-deploy.yaml +++ b/.github/workflows/docs-deploy.yaml @@ -20,8 +20,7 @@ name: Docs Deployment on: # Runs on pushes targeting the main branch push: - branches: - - main + branches: [ main ] paths: - 'docs/**' - 'workflows/**' diff --git a/.github/workflows/helm-chart-lint.yaml b/.github/workflows/helm-chart-lint.yaml index fb80d04e..eac0d5bb 100644 --- a/.github/workflows/helm-chart-lint.yaml +++ b/.github/workflows/helm-chart-lint.yaml @@ -20,7 +20,7 @@ on: workflow_dispatch: pull_request: types: [opened, synchronize, reopened] - branches: [main] + branches: [ main, 'feature/**' ] paths: - 'deployments/charts/**' - '.github/workflows/helm-chart-lint.yaml' diff --git a/.github/workflows/pr-checks.yaml b/.github/workflows/pr-checks.yaml index faa048e1..b64130df 100644 --- a/.github/workflows/pr-checks.yaml +++ b/.github/workflows/pr-checks.yaml @@ -20,7 +20,7 @@ on: workflow_dispatch: pull_request: types: [opened, synchronize, reopened, closed] - branches: [ main ] + branches: [ main, 'feature/**' ] concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number }} diff --git a/.github/workflows/pr-description-check.yaml b/.github/workflows/pr-description-check.yaml index 42c06385..bf42da6c 100644 --- a/.github/workflows/pr-description-check.yaml +++ b/.github/workflows/pr-description-check.yaml @@ -19,7 +19,7 @@ name: PR Description Check on: pull_request: types: [opened, synchronize, reopened, edited] - branches: [main] + branches: [ main, 'feature/**' ] concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number }} diff --git a/.github/workflows/sync-feature-branches.yaml b/.github/workflows/sync-feature-branches.yaml new file mode 100644 index 00000000..7e46fe6b --- /dev/null +++ b/.github/workflows/sync-feature-branches.yaml @@ -0,0 +1,150 @@ +# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 + +name: Sync Feature Branches + +on: + workflow_dispatch: + schedule: + # Run every Monday at 9am PT (5pm UTC) + - cron: '0 17 * * 1' + +jobs: + sync-feature-branches: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch all branches and history + + - name: Configure Git + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + - name: Find and sync feature branches + env: + GH_TOKEN: ${{ github.token }} + run: | + set -e + + echo "🔍 Finding feature branches..." + + # Get all remote feature branches + feature_branches=$(git branch -r | grep 'origin/feature/' | sed 's|origin/||' | grep -v HEAD || true) + + if [ -z "$feature_branches" ]; then + echo "â„šī¸ No feature branches found matching pattern 'feature/*'" + exit 0 + fi + + echo "Found feature branches:" + echo "$feature_branches" + echo "" + + # Process each feature branch + for branch in $feature_branches; do + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" + echo "📋 Processing branch: $branch" + + # Check if main has commits not in the feature branch + git fetch origin main + git fetch origin "$branch" + + commits_behind=$(git rev-list --count origin/$branch..origin/main) + + if [ "$commits_behind" -eq 0 ]; then + echo "✅ Branch $branch is already up to date with main" + continue + fi + + echo "📊 Branch $branch is $commits_behind commit(s) behind main" + + # Extract issue number from branch name (format: feature/PROJ-NNN-short-slug) + # If no PROJ-NNN pattern is found, use "Issue - None" + issue_number=$(echo "$branch" | grep -oE 'PROJ-[0-9]+' || echo "") + if [ -z "$issue_number" ]; then + issue_ref="Issue - None" + else + issue_ref="Issue #$issue_number" + fi + + # Create a temporary branch for the merge + temp_branch="sync/$branch/$(date +%Y%m%d-%H%M)" + + echo "đŸŒŋ Creating temporary branch: $temp_branch" + git checkout -b "$temp_branch" "origin/$branch" + + # Attempt to merge main + echo "🔀 Merging main into $temp_branch..." + if git merge origin/main --no-commit --no-ff; then + echo "✅ Merge successful (no conflicts)" + else + echo "âš ī¸ Merge has conflicts - will create PR for manual resolution" + git add -A + git commit -m "Merge main into $branch" + fi + + # Push the temporary branch + echo "âŦ†ī¸ Pushing $temp_branch to remote..." + git push origin "$temp_branch" + + # Create PR + echo "📝 Creating pull request..." + + gh pr create \ + --base "$branch" \ + --head "$temp_branch" \ + --title "Sync main into $branch" \ + --body "$(cat <