Search code examples
githubgithub-actions

Github action to assign reviewers based on labels is not executed when labels are set by another action


on a private GitHub repository of our Organization, we're using the labeler github action to give our PRs tags based on which files are modified:

name: "Pull Request Labeler"
on:
- pull_request

jobs:
  labeler:
    permissions:
      contents: read
      pull-requests: write
    runs-on: ubuntu-latest
    steps:
    - uses: actions/labeler@v5

It works fine, the correct labels are applied.

We also use the auto-assign-action to assign specific people as reviewers, based on the labels of the PRs:

name: 'Auto Assign'
on:
  pull_request:
    types: [labeled, unlabeled]

jobs:
  add-reviews-dev:
    runs-on: ubuntu-latest
    steps:
      - uses: kentaro-m/[email protected]
        with:
          configuration-path: '.github/auto_assign_dev.yml'

  add-reviews-art:
    runs-on: ubuntu-latest
    steps:
      - uses: kentaro-m/[email protected]
        with:
          configuration-path: '.github/auto_assign_art.yml'

Unfortunately, that second github action is never executed when the first one adds labels.

But if I manually remove the labels that the first action added, and re-apply them again, then the second action is triggered and sets the reviewers correctly.

I also tried to:

  • add the jobs add-reviews-dev and add-reviews-art in the same pipeline as the label (using the needs keyword to make sure they are executed after)
  • manually call the auto-assign action from the labeler action with the uses keyword in the latter and the workflow_call keyword in the former

But those two tries were not successful.

Is there a way to do that?


Solution

  • GitHub actions will not trigger on any changes made by an action that uses the GIDHUB_TOKEN that's set by the agent. GitHub recognizes this as an action token and won't trigger any new workflows to prevent cascades.

    You have a few options:

    1. Use a Callable workflow trigger and call other workflow from the one making the changes
    2. Use the GitHub cli or a direct REST call to start the other workflow.
    3. Capture the tag change logic in a composite action and call it directly in the making the changes as well as the other workflow.
    4. Use a GitHub App's token to change the tags.
    5. Use a personal access token to change the tags.