Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 2
Message 1 of 3

on pull_request labeled

Solved! Go to Solution.
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.
2 Replies
Highlighted
Solution
GitHub Partner
Message 2 of 3

Re: on pull_request labeled

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.

example.PNG

Copilot Lvl 2
Message 3 of 3

Re: on pull_request labeled

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.