Search code examples
github-actionsbuilding-github-actions

How to check for a label in a github action condition


Let's say I have a github action like this:

name: My Action

on:
  pull_request:
    types:
      - closed

jobs:
  myjob:
    runs-on: ubuntu-latest
    name: Test
    if: github.event.pull_request.merged && XXX

I would like to have a condition here to test the presence of a label.

From the docs, using contains( github.event.pull_request.labels, 'my_label')doesn't seem appropriate since it's a dictionary and not an array.

Is there any way around this?


Solution

  • Finally found it:

    contains( github.event.pull_request.labels.*.name, 'My Label')