Skip to content

Github Action to sync labels in a particular repo with a yaml file for easy cross repo configuration.

License

Notifications You must be signed in to change notification settings

DrBarnabus/label-sync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

label-sync

Github Action to sync labels in a particular repo with a yaml file for easy cross repo configuration.

Example

.github/labels.yml

labels:
- name: bug
  description: 'Label for a bug'
  color: 'd73a4a'
- name: feature
  color: '00ff00'

.github/workflows/label-sync.yml

name: 'Label Sync'
on:
  push:
    branches:
    - main
    paths:
    - .github/workflows/label-sync.yml
    - .github/labels.yml

jobs:
  label-sync:
    name: 'Sync Labels'
    runs-on: ubuntu-latest
    steps:
    - uses: DrBarnabus/label-sync@v1
      with:
        github-token: ${{ secrets.GITHUB_TOKEN }}

Workflow Parameters

github-token - The GitHub API Token, for example ${{ secrets.GITHUB_TOKEN }} config-path - Optional override for the path to the configuration file. Defaults to .github/labels.yml owner - Optional override for the repo owner to apply to (if not appling to this repo) repo - Optional override for the repo to apply to (if not appling to this repo)

Applying to multiple repos

Although recommended to have a labels.yml in each repository you are managing. In an advanced use case, you may want to have a global configuration for your labels and apply to many repos in the same organization/user (or even across multiple organizations/users).

To achieve this you must provide a PAT (Personal access token) for a github account with access to all repos. You can the use a workflow configuration similar to below to run the step for all repos listed.

.github/workflows/label-sync.yml

name: 'Label Sync'
on:
  push:
    branches:
    - main
    paths:
    - .github/workflows/label-sync.yml
    - .github/labels.yml

jobs:
  label-sync:
    name: 'Sync Labels'
    runs-on: ubuntu-latest
    strategy:
      matrix:
        repo: ['repo-one', 'repo-two', 'repo-three']
    steps:
    - uses: DrBarnabus/label-sync@v1
      with:
        github-token: ${{ secrets.GITHUB_PAT }}
        owner: 'DrBarnabus'
        repo: ${{ matrix.repo }}

To sync to multiple organizations/users add more jobs with the appropriate repositories listed.

About

Github Action to sync labels in a particular repo with a yaml file for easy cross repo configuration.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •