on pull_request labeled

We can tell an action to run when a label is added (or removed), but I can’t seem to narrow the action to _which_ label was added.

Anyone know how to accomplish this? With the hcl syntax, GitHub recommended using the filter action to stop a run. The yaml syntax is way better, but this functionality seems to be missing.

3 Likes

Hi @dudo,

At this moment, it does not support to set filter of labels on the label event. Any label is created, edited or deleted will trigger the workflow to run.

As a workaround, you syntax  jobs.<job_id>.if  to set conditions to decide which labels can let the jobs run or not.

For example:

The labels _ testLab01 _ and _ testLab02 _ are created, edited or deleted will not let  first_job be executed.

jobs:
first_job:
if: github.event_name == 'label' && github.event.label.name != 'testLab01' && github.event.label.name != 'testLab02'
name: First Job

Only the label _ bug _ is created, edited or deleted will let second_job be executed.

jobs:
  second_job:
    if: github.event_name == 'label' && github.event.label.name == 'bug'
    name: Second Job

Note:

  1. This workaround can’t prevent the workflow from running, the workflow will still run. It just can prevent the jobs from running during runing the workflow.

  2. If you want the conditions can be available to all jobs, you need to add the conditions on every job.

1 Like

Seems like you might be on the team - any plans on adding this functionality? Your solution is very similar to the original “filter” solution, but more robust label support would be pretty powerful.

2 Likes