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

Combined usage with actions/labeler #57

Closed
jenssimon opened this issue Aug 1, 2023 · 7 comments
Closed

Combined usage with actions/labeler #57

jenssimon opened this issue Aug 1, 2023 · 7 comments

Comments

@jenssimon
Copy link

Are there recommendations how to use this action combined with actions/labeler?

Question

What happens when both workflows run at the same time?

Sometimes this configuration leads to moments like

github-actions bot added 🗂 foo 🗂 bar dependencies and removed 🗂 foo 🗂 bar labels 4 minutes ago

I think

  • pull_request and pull_request_target - no difference between workflow execution for both events
  • it could happen that both workflows run at the same time

I haven't checked yet if it makes sense to run both actions within the same workflow.

💡 I wonder if there is a recommendation how to use both actions within the same repo.

Example code

Currently I run this configuration for a project using a monorepo:

# .github/workflows/labeler.yml
name: Pull Request Labeler
on:
  - pull_request_target

jobs:
  triage:
    permissions:
      contents: read
      pull-requests: write
    runs-on: ubuntu-latest
    steps:
      - uses: actions/labeler@v4
        with:
          repo-token: "${{ secrets.GITHUB_TOKEN }}"
          sync-labels: true
# .github/workflows/monorepo-pr-labeler-action.yml
name: Monorepo PR Repo Labeler
on:
  pull_request:
    paths:
    - services/**
    - packages/**

jobs:
  labelPR:
    name: Label PR With Repo(s)
    runs-on: ubuntu-latest
    steps:
      - name: Monorepo PR Repo Labeler
        uses: TinkurLab/monorepo-pr-labeler-action@4.1.4
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          BASE_DIRS: 'services|packages'
        with:
          prefix: '🗂'
          separator: ' '
# .github/labeler.yml
dependencies:
  - '**/package.json'
  - ...

infra:
  - infrastructure/**/*
  - ...

ci:
  - .github/**
  - ...

So I can label changes for a PR on

  • 🔀 dependencies
  • ⚙️ ci
  • 🗂 packages of the monorepo
@adamzolyak
Copy link
Member

👋 hi @jenssimon. Thanks for sharing your feedback and question. I haven't used https://github.com/actions/labeler yet. I'm curious, why do you need the monorepo labeler and https://github.com/actions/labeler? Can https://github.com/actions/labeler also label the monorepos?

@jenssimon
Copy link
Author

Hi @adamzolyak,

The answer is pretty easy.

TinkurLab/monorepo-pr-labeleler-action

  • label packages in the monorepo that get touched by the PR

actions/labeler

I use this one to label the kind of changes, examples:

  • frontend
  • backend
  • CSS
  • translations
  • dependencies
  • schemas changed
  • infrastructure changes (AWS)
  • etc

So on the pull requests tab you can easily get an overview what has changed.

Globs pattern can be used to identify the kind of change

  • changes on package.json or yarn.lock are most likely about dependencies
  • changes on .github/ folder are ci topics
  • any changes on **/*.css are labeled as css
  • ...

So a really useful tool.

A backend dev might not be interested in reviewing CSS, ...

@jenssimon
Copy link
Author

Can https://github.com/actions/labeler also label the monorepos?

I don't see an easy way to use actions/labeler to label monorepos as this action here does.
Maybe with generated config. But that feels a bit strange.

That's the reason why I use this action in combination with actions/labeler.

It's an action provided by GitHub. Maybe it's a great addition adding "monorepo labeling" to it. Only had a quick look on issues and PRs and haven't seen this topic there.

@kyhule
Copy link

kyhule commented Mar 13, 2024

@jenssimon Not sure if you have since solved this problem but I suspect your use of sync-labels: true is causing actions/labeler to remove the labels applied by TinkurLab/monorepo-pr-labeleler-action.

@jenssimon
Copy link
Author

@kyhule You might be right. I see some activity regarding sync-labels (e.g. actions/labeler#112). Looks like there was a fix within actions/labeler@v5. Haven't checked in detail yet.

Haven't heard any complaints about missing labels for quite some time. The projects running on this setup are using the recent versions of the actions.

I will check and ask the team.

@kyhule
Copy link

kyhule commented Mar 13, 2024

I tested this theory with labeler running it before the monorepo labeler with sync-labels set to true in the same job and it didn't remove the label from the previous run. I tested using v5 so if it was the cause it isn't doing it anymore. I never tried reproducing it on an older version. I found your issue because I was seeing if I could somehow use both actions to remove labels created by monorepo labeler that are no longer applicable since this action doesn't have a sync feature.

@jenssimon
Copy link
Author

Seems my described problems are gone since actions/labeler@v5.

So combined usage is as described in the PR description. But with:

    steps:
-      - uses: actions/labeler@v4
+      - uses: actions/labeler@v5 # or beyond
        with:

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

No branches or pull requests

3 participants