-
Notifications
You must be signed in to change notification settings - Fork 3
Enable automatic workflow approval for Liatrio Labs organization members #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
iaminawe
wants to merge
6
commits into
main
Choose a base branch
from
workflow-org-member-approval
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fce9ad5
Enable automatic workflow approval for Liatrio Labs organization members
iaminawe 215cc73
Use ORG_MEMBER_CHECK_TOKEN for organization membership verification
iaminawe 4c5cdc9
Refactor authorization logic into reusable composite action
iaminawe 2ab5a28
Merge branch 'main' into workflow-org-member-approval
iaminawe a4a675f
Update .github/actions/check-org-membership/action.yml
iaminawe 006097d
Add explicit permissions block to check-org-membership jobs
iaminawe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| name: Check Organization Membership | ||
| description: Checks if a user is authorized via repository permissions or organization membership | ||
|
|
||
| inputs: | ||
| trigger-command: | ||
| description: 'The trigger command to check for (e.g., @claude or /oc-codex)' | ||
| required: true | ||
| github-token: | ||
| description: 'GitHub token with org membership read permissions' | ||
| required: true | ||
| event-name: | ||
| description: 'The GitHub event name (github.event_name)' | ||
| required: true | ||
| comment-body: | ||
| description: 'The comment body if applicable' | ||
| required: false | ||
| default: '' | ||
| comment-author-association: | ||
| description: 'The comment author association if applicable' | ||
| required: false | ||
| default: '' | ||
| review-body: | ||
| description: 'The review body if applicable' | ||
| required: false | ||
| default: '' | ||
| review-author-association: | ||
| description: 'The review author association if applicable' | ||
| required: false | ||
| default: '' | ||
| issue-body: | ||
| description: 'The issue body if applicable' | ||
| required: false | ||
| default: '' | ||
| issue-title: | ||
| description: 'The issue title if applicable' | ||
| required: false | ||
| default: '' | ||
| issue-author-association: | ||
| description: 'The issue author association if applicable' | ||
| required: false | ||
| default: '' | ||
| actor: | ||
| description: 'The GitHub actor (github.actor)' | ||
| required: true | ||
| organization: | ||
| description: 'The organization name to check membership in' | ||
| required: true | ||
| default: 'liatrio-labs' | ||
|
|
||
| outputs: | ||
| is-authorized: | ||
| description: 'Whether the user is authorized to trigger the workflow' | ||
| value: ${{ steps.check.outputs.authorized }} | ||
|
|
||
| runs: | ||
| using: 'composite' | ||
| steps: | ||
| - name: Check authorization | ||
| id: check | ||
| shell: bash | ||
| env: | ||
| GH_TOKEN: ${{ inputs.github-token }} | ||
| TRIGGER_COMMAND: ${{ inputs.trigger-command }} | ||
| EVENT_NAME: ${{ inputs.event-name }} | ||
| COMMENT_BODY: ${{ inputs.comment-body }} | ||
| COMMENT_AUTHOR_ASSOC: ${{ inputs.comment-author-association }} | ||
| REVIEW_BODY: ${{ inputs.review-body }} | ||
| REVIEW_AUTHOR_ASSOC: ${{ inputs.review-author-association }} | ||
| ISSUE_BODY: ${{ inputs.issue-body }} | ||
| ISSUE_TITLE: ${{ inputs.issue-title }} | ||
| ISSUE_AUTHOR_ASSOC: ${{ inputs.issue-author-association }} | ||
| ACTOR: ${{ inputs.actor }} | ||
| ORGANIZATION: ${{ inputs.organization }} | ||
| run: | | ||
| # Determine the author association based on event type | ||
| if [[ "$EVENT_NAME" == "issue_comment" ]] || [[ "$EVENT_NAME" == "pull_request_review_comment" ]]; then | ||
| AUTHOR_ASSOC="$COMMENT_AUTHOR_ASSOC" | ||
| elif [[ "$EVENT_NAME" == "pull_request_review" ]]; then | ||
| AUTHOR_ASSOC="$REVIEW_AUTHOR_ASSOC" | ||
| elif [[ "$EVENT_NAME" == "issues" ]]; then | ||
| AUTHOR_ASSOC="$ISSUE_AUTHOR_ASSOC" | ||
| fi | ||
| # Check if user is a repo collaborator/owner/member first | ||
| if [[ "$AUTHOR_ASSOC" == "OWNER" ]] || [[ "$AUTHOR_ASSOC" == "MEMBER" ]] || [[ "$AUTHOR_ASSOC" == "COLLABORATOR" ]]; then | ||
| echo "User is authorized via author_association: $AUTHOR_ASSOC" | ||
| echo "authorized=true" >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
| # Check if user is a member of the organization | ||
| if gh api "orgs/$ORGANIZATION/members/$ACTOR" --silent 2>/dev/null; then | ||
| echo "User is authorized as $ORGANIZATION organization member" | ||
| echo "authorized=true" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "User is not authorized" | ||
| echo "authorized=false" >> "$GITHUB_OUTPUT" | ||
| fi | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.