Skip to content

JulienKode/team-labeler-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Team Labeler Action 👥

build test GitHub issues GitHub forks GitHub stars GitHub license Watch on GitHub Tweet

This repository provides a GitHub action to automatically team label on a pull request based author team. This is useful if multiple team are working on the same project.

example

Configuration

Create .github/teams.yml

You need to provide a yml file that contains members of your teams:

LightSide:
  - '@Yoda'
  - '@Luke'

DarkSide:
  - '@DarkVador'
  - '@Palpatine'

GitHub Team Support

You can also use GitHub team names to automatically apply labels based on team membership. To do this:

Include team names in your configuration using the format @organization/team-slug:

FrontendTeam:
  - '@YourOrg/frontend'
  
BackendTeam:
  - '@YourOrg/backend'

Usage

Create .github/workflows/team-labeler.yml

Create a workflow (eg: .github/workflows/team-labeler.yml see Creating a Workflow file) to utilize the labeler action. This action only needs the GITHUB_TOKEN secret as it interacts with the GitHub API to modify labels. It's working for pull request and issues. The action can be used as such:

on:
  pull_request:
  issues:
name: team-label
permissions:
  contents: read
  pull-requests: write
  issues: write # Necessary to create the labels if they do not exist yet.
jobs:
  team-labeler:
    runs-on: ubuntu-latest
    steps:
    - uses: JulienKode/team-labeler-action@v2.0.1
      with:
        repo-token: "${{ secrets.GITHUB_TOKEN }}"
        # Optional: Add if you want to use GitHub team-based labeling
        org-token: "${{ secrets.ORG_TOKEN }}"

Required Permissions

  1. For basic functionality, the workflow needs:

    • contents: read
    • pull-requests: write (to apply labels to pull requests)
    • issues: write (to apply labels to issues and create labels if they do not exist yet)
  2. For GitHub team integration, you need to:

    • Create a Personal Access Token with read:org permission
    • Add this token as a repository secret (e.g., ORG_TOKEN)
    • Pass this token to the action using the org-token parameter

Note: While the issues:write permission does allow for creating labels through GitHub's API.