diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 1801896..737be4b 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @abhijeetviswam +* @abhijeetviswam diff --git a/.github/workflows/pr-validation.yml b/.github/workflows/pr-validation.yml new file mode 100644 index 0000000..f8124a3 --- /dev/null +++ b/.github/workflows/pr-validation.yml @@ -0,0 +1,44 @@ +name: PR Validation + +on: + pull_request: + types: [opened, synchronize, reopened, labeled, unlabeled] + +permissions: + contents: read + pull-requests: read + +jobs: + validate: + runs-on: ubuntu-latest + + steps: + # 1️⃣ Checkout the PR branch first + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 # fetch full history so git log and rebase work + + # 2️⃣ Fetch main to rebase + - name: Fetch main branch + run: git fetch origin develop + + # 3️⃣ Rebase PR onto main + - name: Rebase on main + run: | + git rebase origin/develop || ( + echo "❌ Rebase failed. Please rebase your branch on main." && exit 1 + ) + + # 5️⃣ Check if QA label exists + - name: Check for QA-Approved label + run: | + echo "Checking for QA-Approved label..." + LABELS=$(gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels[].name') + echo "Labels found: $LABELS" + if [[ "$LABELS" != *"QA-Approved"* ]]; then + echo "❌ Missing QA-Approved label. QA must approve before merge." + exit 1 + fi + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}