Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 205
Denis Rouzaud Avatar asked Jan 04 '20 06:01

Denis Rouzaud


People also ask

How do I test a workflow action in GitHub?

One way to test Github actions is to create a private repo, and iterate the actions conf there. So you can avoid polluting the actual repo with broken commits.

Can you CD in GitHub Actions?

With GitHub Actions, you can trigger CI/CD workflows and pipelines of webhooks from these apps (even something simple, like a chat app message, if you've integrated your chat app into your GitHub repository, of course).

What is ID in GitHub Actions?

ID is used as a reference, from other jobs or steps (for example, in jobs. <job_id>. needs ). Name is used for display purposes on GitHub.


1 Answers

Finally found it:

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

like image 66
Denis Rouzaud Avatar answered Oct 15 '22 06:10

Denis Rouzaud