Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 22, 2026

Adds a manually-triggered workflow that allows members of the "org-managers" team to send organization invitations to specified GitHub users via the REST API.

Implementation

  • Workflow trigger: workflow_dispatch with required username input
  • Authorization: Validates actor is member of "org-managers" team using /orgs/{org}/teams/{team}/members/{user} endpoint
  • Input validation: Regex pattern ^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?$ with 39-char limit
  • API call: PUT /orgs/{org}/memberships/{username} with role='member'
  • Permissions: Explicit contents: read only

Setup Requirements

  1. Create "org-managers" team in organization
  2. Add PAT_TOKEN secret with admin:org and read:org scopes
on:
  workflow_dispatch:
    inputs:
      username:
        description: 'GitHub username to add to the organization'
        required: true
        type: string

Workflow fails fast if actor lacks team membership or username format is invalid. No sensitive data logged in error messages.

Original prompt

On workflows, I would like to create a new github action workflow that is run manually, receiving a string input named "username". The workflow will then check that the user running it is a member of a specific group (lets call it "org-managers"), and if so, will attempt to add that user to the current organization via the Github REST API, using a PAT stored as a secret.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits January 22, 2026 19:21
Co-authored-by: eb-oss <1403599+eb-oss@users.noreply.github.com>
Co-authored-by: eb-oss <1403599+eb-oss@users.noreply.github.com>
Co-authored-by: eb-oss <1403599+eb-oss@users.noreply.github.com>
Co-authored-by: eb-oss <1403599+eb-oss@users.noreply.github.com>
Copilot AI changed the title [WIP] Add manual GitHub action to add user to organization Add workflow for org-managers to invite users to organization Jan 22, 2026
Copilot AI requested a review from eb-oss January 22, 2026 19:26
@eb-oss eb-oss marked this pull request as ready for review January 23, 2026 03:52
@eb-oss eb-oss merged commit f0078a5 into main Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants