Skip to content
This repository was archived by the owner on Sep 5, 2025. It is now read-only.

Commit 6efa839

Browse files
committed
Check comment author for organization membership in both issue-fix and issue-analyze modes
1 parent decced3 commit 6efa839

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

.github/workflows/claude-full.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,14 @@ jobs:
4949
run: |
5050
ISSUE_NUMBER="${{ github.event.issue.number }}"
5151
FEEDBACK="${{ github.event.comment.body }}"
52+
COMMENT_AUTHOR="${{ github.event.comment.user.login }}"
5253
# Remove the "claude:" prefix
5354
FEEDBACK="${FEEDBACK#claude:}"
5455
# Remove newlines from feedback to prevent GitHub Actions output issues
5556
FEEDBACK_CLEANED="$(echo "$FEEDBACK" | tr '\n' ' ')"
5657
echo "number=${ISSUE_NUMBER}" >> $GITHUB_OUTPUT
5758
echo "feedback=${FEEDBACK_CLEANED}" >> $GITHUB_OUTPUT
59+
echo "comment_author=${COMMENT_AUTHOR}" >> $GITHUB_OUTPUT
5860
5961
- name: Process with Claude Code for issue analysis
6062
uses: basicmachines-co/[email protected]
@@ -68,6 +70,7 @@ jobs:
6870
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
6971
github-token: ${{ github.token }}
7072
personal-access-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
73+
comment-author: ${{ steps.issue.outputs.comment_author }}
7174

7275
- name: Upload claude output artifacts
7376
if: always()
@@ -105,12 +108,14 @@ jobs:
105108
run: |
106109
ISSUE_NUMBER="${{ github.event.issue.number }}"
107110
FEEDBACK="${{ github.event.comment.body }}"
111+
COMMENT_AUTHOR="${{ github.event.comment.user.login }}"
108112
# Remove the "claude-fix:" prefix
109113
FEEDBACK="${FEEDBACK#claude-fix:}"
110114
# Remove newlines from feedback to prevent GitHub Actions output issues
111115
FEEDBACK_CLEANED="$(echo "$FEEDBACK" | tr '\n' ' ')"
112116
echo "number=${ISSUE_NUMBER}" >> $GITHUB_OUTPUT
113117
echo "feedback=${FEEDBACK_CLEANED}" >> $GITHUB_OUTPUT
118+
echo "comment_author=${COMMENT_AUTHOR}" >> $GITHUB_OUTPUT
114119
115120
- name: Process with Claude Code for issue fix
116121
uses: basicmachines-co/[email protected]
@@ -126,6 +131,7 @@ jobs:
126131
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
127132
github-token: ${{ github.token }}
128133
personal-access-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
134+
comment-author: ${{ steps.issue.outputs.comment_author }}
129135

130136
- name: Upload claude output artifacts
131137
if: always()

action.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ inputs:
6565
personal-access-token:
6666
description: 'Optional personal access token for commits, to override the default GitHub token'
6767
required: false
68+
comment-author:
69+
description: 'The GitHub username of the person who made the comment'
70+
required: false
6871
output-file:
6972
description: 'Path to write the output to (for direct mode)'
7073
required: false
@@ -121,11 +124,11 @@ runs:
121124
shell: bash
122125
run: |
123126
chmod +x ${{ github.action_path }}/scripts/issue-fix-mode.sh
124-
${{ github.action_path }}/scripts/issue-fix-mode.sh "${{ inputs.issue-number }}" "${{ inputs.repo-owner }}" "${{ inputs.repo-name }}" "${{ inputs.branch-prefix }}" "${{ inputs.anthropic-api-key }}" "${{ inputs.github-token }}" "${{ inputs.issue-label }}" "${{ inputs.debug-mode }}" "${{ inputs.feedback }}" "${{ inputs.require-org-membership }}" "${{ inputs.organization }}" "${{ inputs.personal-access-token }}"
127+
${{ github.action_path }}/scripts/issue-fix-mode.sh "${{ inputs.issue-number }}" "${{ inputs.repo-owner }}" "${{ inputs.repo-name }}" "${{ inputs.branch-prefix }}" "${{ inputs.anthropic-api-key }}" "${{ inputs.github-token }}" "${{ inputs.issue-label }}" "${{ inputs.debug-mode }}" "${{ inputs.feedback }}" "${{ inputs.require-org-membership }}" "${{ inputs.organization }}" "${{ inputs.personal-access-token }}" "${{ inputs.comment-author }}"
125128
126129
- name: Process Issue Analysis
127130
if: inputs.mode == 'issue-analyze'
128131
shell: bash
129132
run: |
130133
chmod +x ${{ github.action_path }}/scripts/issue-analyze-mode.sh
131-
${{ github.action_path }}/scripts/issue-analyze-mode.sh "${{ inputs.issue-number }}" "${{ inputs.repo-owner }}" "${{ inputs.repo-name }}" "${{ inputs.anthropic-api-key }}" "${{ inputs.github-token }}" "${{ inputs.debug-mode }}" "${{ inputs.feedback }}" "${{ inputs.require-org-membership }}" "${{ inputs.organization }}"
134+
${{ github.action_path }}/scripts/issue-analyze-mode.sh "${{ inputs.issue-number }}" "${{ inputs.repo-owner }}" "${{ inputs.repo-name }}" "${{ inputs.anthropic-api-key }}" "${{ inputs.github-token }}" "${{ inputs.debug-mode }}" "${{ inputs.feedback }}" "${{ inputs.require-org-membership }}" "${{ inputs.organization }}" "${{ inputs.personal-access-token }}" "${{ inputs.comment-author }}"

scripts/issue-analyze-mode.sh

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ FEEDBACK=$7
1313
REQUIRE_ORG_MEMBERSHIP=${8:-"true"}
1414
ORGANIZATION=${9:-$REPO_OWNER}
1515
PERSONAL_ACCESS_TOKEN=${10:-$GITHUB_TOKEN}
16+
COMMENT_AUTHOR=${11:-""}
1617

1718
# Enable debug mode if requested
1819
if [[ "$DEBUG_MODE" == "true" ]]; then
@@ -108,25 +109,34 @@ ISSUE_AUTHOR=$(echo "$ISSUE_DETAILS" | jq -r '.author.login')
108109

109110
# Check if user is a member of the organization if required
110111
if [[ "$REQUIRE_ORG_MEMBERSHIP" == "true" ]]; then
111-
echo "Checking if $ISSUE_AUTHOR is a member of organization $ORGANIZATION"
112+
# Use the comment author for the org membership check if provided, otherwise fall back to issue author
113+
CHECK_USER="${COMMENT_AUTHOR:-$ISSUE_AUTHOR}"
114+
echo "Checking if $CHECK_USER is a member of organization $ORGANIZATION"
115+
116+
# Debug output
117+
echo "Comment Author: $COMMENT_AUTHOR"
118+
echo "Issue Author: $ISSUE_AUTHOR"
119+
echo "User being checked: $CHECK_USER"
112120

113121
# Temporarily use the personal access token for org membership check if provided
114122
if [[ "$PERSONAL_ACCESS_TOKEN" != "$GITHUB_TOKEN" ]]; then
123+
echo "Using Personal Access Token for organization membership check"
115124
# Save current token auth
116125
TEMP_AUTH=$(gh auth status 2>&1 | grep "Logged in")
117126
# Switch to personal token for org check
118127
echo "$PERSONAL_ACCESS_TOKEN" | gh auth login --with-token
119-
ORG_CHECK=$(gh api -X GET /orgs/$ORGANIZATION/members/$ISSUE_AUTHOR --silent -i || true)
128+
ORG_CHECK=$(gh api -X GET /orgs/$ORGANIZATION/members/$CHECK_USER --silent -i || true)
120129
# Switch back to github token
121130
echo "$GITHUB_TOKEN" | gh auth login --with-token
122131
else
123-
ORG_CHECK=$(gh api -X GET /orgs/$ORGANIZATION/members/$ISSUE_AUTHOR --silent -i || true)
132+
echo "Using GitHub Token for organization membership check"
133+
ORG_CHECK=$(gh api -X GET /orgs/$ORGANIZATION/members/$CHECK_USER --silent -i || true)
124134
fi
125135

126136
STATUS_CODE=$(echo "$ORG_CHECK" | head -n 1 | cut -d' ' -f2)
127137

128138
if [[ "$STATUS_CODE" != "204" ]]; then
129-
echo "User $ISSUE_AUTHOR is not a member of organization $ORGANIZATION. Skipping Claude analysis."
139+
echo "User $CHECK_USER is not a member of organization $ORGANIZATION. Skipping Claude analysis."
130140

131141
# Leave a comment on the issue explaining why the analysis is skipped
132142
ISSUE_COMMENT=$(cat <<EOF
@@ -147,7 +157,7 @@ EOF
147157
echo "Exiting due to non-organization member request"
148158
exit 0
149159
else
150-
echo "User $ISSUE_AUTHOR is a member of organization $ORGANIZATION. Proceeding with Claude analysis."
160+
echo "User $CHECK_USER is a member of organization $ORGANIZATION. Proceeding with Claude analysis."
151161
fi
152162
fi
153163

0 commit comments

Comments
 (0)