diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml index 9b146591..422563fe 100644 --- a/.github/workflows/claude.yml +++ b/.github/workflows/claude.yml @@ -126,6 +126,7 @@ jobs: DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} ISSUE_NUMBER: ${{ github.event.issue.number }} ISSUE_TITLE: ${{ github.event.issue.title }} + PR_ASSIGNEE: ${{ vars.CLAUDE_PR_ASSIGNEE }} run: | if [ -z "$CLAUDE_BRANCH" ]; then echo "Claude did not create a branch. Skipping PR creation." @@ -150,8 +151,14 @@ jobs: BODY=$(printf "Closes #%s\n\nCreated automatically from Claude Code branch \`%s\`." "$ISSUE_NUMBER" "$CLAUDE_BRANCH") + ASSIGNEE_ARGS=() + if [ -n "$PR_ASSIGNEE" ]; then + ASSIGNEE_ARGS=(--assignee "$PR_ASSIGNEE") + fi + gh pr create \ --head "$CLAUDE_BRANCH" \ --base "$DEFAULT_BRANCH" \ --title "$TITLE" \ - --body "$BODY" + --body "$BODY" \ + "${ASSIGNEE_ARGS[@]}" diff --git a/templates/workflows/claude.yml b/templates/workflows/claude.yml index 07eb2a70..d61a2451 100644 --- a/templates/workflows/claude.yml +++ b/templates/workflows/claude.yml @@ -141,6 +141,7 @@ jobs: DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} ISSUE_NUMBER: ${{ github.event.issue.number }} ISSUE_TITLE: ${{ github.event.issue.title }} + PR_ASSIGNEE: ${{ vars.CLAUDE_PR_ASSIGNEE }} run: | if [ -z "$CLAUDE_BRANCH" ]; then echo "Claude did not create a branch. Skipping PR creation." @@ -165,8 +166,14 @@ jobs: BODY=$(printf "Closes #%s\n\nCreated automatically from Claude Code branch \`%s\`." "$ISSUE_NUMBER" "$CLAUDE_BRANCH") + ASSIGNEE_ARGS=() + if [ -n "$PR_ASSIGNEE" ]; then + ASSIGNEE_ARGS=(--assignee "$PR_ASSIGNEE") + fi + gh pr create \ --head "$CLAUDE_BRANCH" \ --base "$DEFAULT_BRANCH" \ --title "$TITLE" \ - --body "$BODY" + --body "$BODY" \ + "${ASSIGNEE_ARGS[@]}" diff --git a/test/claude-workflow-contract.test.js b/test/claude-workflow-contract.test.js index 672cab73..4bf7314d 100644 --- a/test/claude-workflow-contract.test.js +++ b/test/claude-workflow-contract.test.js @@ -63,6 +63,9 @@ describe('Claude workflow contracts', () => { expect(workflow).toContain('name: Create pull request from Claude branch'); expect(workflow).toContain('GH_TOKEN: ${{ secrets.CLAUDE_PR_GITHUB_TOKEN || github.token }}'); expect(workflow).toContain('gh pr create'); + expect(workflow).toContain('PR_ASSIGNEE: ${{ vars.CLAUDE_PR_ASSIGNEE }}'); + expect(workflow).toContain('ASSIGNEE_ARGS=(--assignee "$PR_ASSIGNEE")'); + expect(workflow).toContain('"${ASSIGNEE_ARGS[@]}"'); expect(workflow).toContain('git ls-remote --exit-code --heads origin "$CLAUDE_BRANCH"'); // 変更なしタスク(ブランチ未push)は正常終了として扱う(false failure 防止) expect(workflow).toContain('Claude branch $CLAUDE_BRANCH was not pushed (no code changes). Skipping PR creation.');