Skip to content
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

Feature Request: Can this be turned into a GitHub App? #4

Open
Mariatta opened this issue Jan 29, 2019 · 10 comments Β· May be fixed by #36
Open

Feature Request: Can this be turned into a GitHub App? #4

Mariatta opened this issue Jan 29, 2019 · 10 comments Β· May be fixed by #36
Labels
discussion Issues for discussing ideas for features enhancement New feature or enhancement for labels

Comments

@Mariatta
Copy link

Thanks for this project, I found it really useful, but I'm uh... lazy.. when it comes to command line πŸ˜₯ πŸ™‡β€β™€οΈ

I think it would be great for this to exists as a GitHub App, and easily installed to any repo we like.
I'll be interested to help build such app :)

@hackebrot
Copy link
Owner

Yes! I love that idea! πŸ˜ƒ :octocat:

@hackebrot hackebrot added discussion Issues for discussing ideas for features enhancement New feature or enhancement for labels labels Jan 31, 2019
@michaeljoseph
Copy link

πŸ‘‹ @Mariatta
I'm curious about how the app would work? What events would it be responding to?

@mariatta-bot
Copy link

πŸ€– Mariatta was mentioned, but she's out of open source until end of September 2019. Hopefully someone else can look into this in the meantime.

@hackebrot
Copy link
Owner

Hi @michaeljoseph! πŸ‘‹

Mariatta and I chatted about how the GitHub app would work offline and we came up with the following design. πŸ“

Adding the app

When the app is added to a GitHub repo it will check for a labels file on the repo's default branch.

  • If it can't find one it will use fetch to create one based on the repo's GitHub labels and commit the file on the repo's default branch.
  • If it can find one it will use fetch to update it based on the repo's GitHub labels and commit the changed file to the repo's default branch.

GitHub label event

When a user modifies a GitHub label of a repo, the labels app will react to event and use fetch to update the labels file and commit the changed file to the repo's default branch.

GitHub push event

When a users pushes commits to the repo's default branch, the labels app will react to the event and check whether the commit modifies the labels file.

If the file was modified, the labels app will use sync to update the repo's GitHub labels and commit the changed labels file (sync updates the labels file, so that TOML section names match the name parameter).

GitHub pull request event

When a new pull-request is created, the labels app will react to the event and check whether it modifies the labels file.

If the file was modified, the labels app use sync with the dryrun option and comment on the pull-request how merging the pull-request would change the repo's GitHub labels.


I think it would be really cool if we could implement this idea as a GitHub Action! πŸ€–

I'm curious to hear what you think about our design!

@hackebrot
Copy link
Owner

Other use cases

(notes from @Mariatta and my chat at PyCon DE)

  • import from another repository
  • export to other repositories
  • keep labels in sync across repositories in org (select labels)

@mariatta-bot
Copy link

πŸ€– Mariatta was mentioned, but she's out of open source until end of September 2019. Hopefully someone else can look into this in the meantime.

@hackebrot
Copy link
Owner

What do you think @michaeljoseph? πŸ˜ƒ

@jean
Copy link
Contributor

jean commented Feb 6, 2020

I just noticed that there is a GitHub Action based on labels: https://github.com/marketplace/actions/manage-issue-labels
It looks like it allows defining a master repo that pushes out labels to multiple other repos, but I couldn't figure out exactly how that works yet.

@tprasadtp
Copy link
Contributor

@jean I created it. You can define labels in .github/labels.toml(default) and use it as

on:
  push:
    branches:
      - master
name: labels
jobs:
  labels:
    name: labels
    runs-on: ubuntu-latest
    steps:
    - name: sync labels
      uses: tprasadtp/labels@master # Prefer using a tagged version!!!
      with:
        token: ${{ secrets.GITHUB_TOKEN }}

It will sync the labels, for the repo in which actions is being executed. To manage labels for multiple repos in a single workflow, you have to use builds matrix and a Personal Access Token.

jobs:
  labels:
    name: labels
    runs-on: ubuntu-latest
     strategy:
      fail-fast: false
      matrix:
        repo: [ "repo1", "repo2", "repo3", "repo4"]
    steps:
    - uses: actions/checkout@v2
    - name: sync labels
      uses: tprasadtp/labels@master # Prefer using a tagged version!!!
      with:
        file: .github/labels.toml
        repo: ${{ matrix.repo }}
        token: ${{ secrets.PAT }}

Note: It only works on x86_64 and Linux.

@browniebroke browniebroke linked a pull request Oct 12, 2023 that will close this issue
@browniebroke
Copy link

browniebroke commented Oct 12, 2023

I've setup a GitHub action in my projects to run labels on push to main, when the changes look relevant. I'm pretty sure I copied it from somewhere else a while back, but I can't remember where...

name: Sync Github labels

on:
  push:
    branches:
      - main
    paths:
      - ".github/**"

jobs:
  labels:
    runs-on: ubuntu-latest

    permissions:
      issues: write

    steps:
      - uses: actions/checkout@v4
      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: 3.x
      - name: Install labels
        run: pip install labels
      - name: Sync config with Github
        run: labels -u ${{ github.repository_owner }} -t ${{ secrets.GITHUB_TOKEN }} sync -f .github/labels.toml

I recently managed to tweak it with the right permissions, so it works with the native GITHUB_TOKEN, scoped to give write access to the issues.

I've put together pull request #36 to simplify the user-land setup a bit and document its usage.

Suggestions welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Issues for discussing ideas for features enhancement New feature or enhancement for labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants