diff --git a/.github/workflows/auto-pr.yml b/.github/workflows/auto-pr.yml new file mode 100644 index 0000000..47a9f17 --- /dev/null +++ b/.github/workflows/auto-pr.yml @@ -0,0 +1,54 @@ +name: Auto Create PR + +on: + push: + branches: + - 'feat/**' + - 'fix/**' + - 'bug/**' + - 'docs/**' + - 'style/**' + - 'refactor/**' + - 'perf/**' + - 'test/**' + - 'build/**' + - 'ci/**' + - 'chore/**' + - 'revert/**' + +permissions: + pull-requests: write + contents: read + +jobs: + create-pr: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Check and create PR + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + BRANCH_NAME="${GITHUB_REF#refs/heads/}" + + # Check if an open PR already exists from this branch to main + PR_COUNT=$(gh pr list --head "$BRANCH_NAME" --base main --state open --json id --jq 'length') + + if [ "$PR_COUNT" -eq 0 ]; then + echo "No open PR found for branch '$BRANCH_NAME'. Creating one..." + + # Format the title (e.g., 'feat/my-feature' -> 'feat: my feature') + TITLE=$(echo "$BRANCH_NAME" | sed -E 's|^([^/]+)/(.*)|\1: \2|' | tr '-' ' ') + + gh pr create \ + --head "$BRANCH_NAME" \ + --base main \ + --title "$TITLE" \ + --body "Automated PR created from branch \`$BRANCH_NAME\`." + + echo "PR created successfully." + else + echo "An open PR already exists for branch '$BRANCH_NAME'. Skipping PR creation." + fi diff --git a/.github/workflows/jules-pr-review.yml b/.github/workflows/jules-pr-review.yml new file mode 100644 index 0000000..2934fd5 --- /dev/null +++ b/.github/workflows/jules-pr-review.yml @@ -0,0 +1,21 @@ +name: Jules PR Review +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + +concurrency: + group: jules-review-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + review: + runs-on: ubuntu-latest + permissions: + pull-requests: write + contents: read + statuses: write + steps: + - uses: sanjay3290/jules-pr-reviewer@v1 + with: + jules_api_key: ${{ secrets.JULES_API_KEY }} + github_token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file