Can a workflow only trigger if a specific PR label has been set? (Similar to tags/branches)

I’ve been using the PR labeled event to run an extra workflow on my PR, if a particular label has been added. The problem is, if another (unrelated) label is added to the PR, the extra workflow is run, which I don’t want (because it discards the results of the first attempt, as far as the CI checks are concerned).

Can we not have support to run (or not run) a workflow based on the label that has triggered the PR.labeled event, similar to how we can with tags & branches? Is this planned?

Hi @johnlbergqvist,

Currently it’s NOT supported with PR.labeled event, it doesn’t have similar value check as tags or branches. It’s recommended to raise a feature_request ticket in below link where github product manager will take a review.[category]=actions

Typically, we will use job level ‘if’ expression to check the new label, skip the workflow if the label name is not expected. However, it will always trigger a workflow for unrelated label.

      - labeled

    runs-on: ubuntu-latest   
    if:'labelcheck2'    # only execute when label 'labelcheck2' is added, however, a workflow will be still created with 'unrelated' label added.


Yes, the problem is when the workflow re-runs, in the “CI checks” area, it will discard any previous runs of that workflow.

So if I add labelcheck2 first, it will run labeltest and that job will show up as passed, which is correct.

However if I was to then add someotherlabel, labeltest would then change from passed to skipped (because the workflow has still re-ran), which would then mean I would be unable to merge that PR if labeltest was a mandatory check.

I have submitted a feeback post requesting this functionality anyway.