Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 3
Message 1 of 3

Labeled action on pull_request

Solved! Go to Solution.

For the life of me I cannot figure this out. What exactly is value of github.event.pull_request.labels? Based on the developer guide, it should be an array of objects, but here, it prints Array, and no matter how I try to loop it in Bash, it prints Array. Is it literally the string "Array"? So how do I find out specific labels that have been applied to a specific pull request? 


name: test

      - master
    types: [labeled]

    runs-on: ubuntu-latest
    - name: current branch
      run: |
        array = ${{ github.event.pull_request.labels }}
        echo "${array[*]}"
2 Replies
Pilot Lvl 1
Message 2 of 3

Re: Labeled action on pull_request

If you use this step to output the entire github context you can see what the JSON looks like.

      - name: Dump GitHub context
          GITHUB_CONTEXT: ${{ toJson(github) }}
        run: echo "$GITHUB_CONTEXT"


I ran it for a PR with two labels and the context output looks like this.

    "labels": [
        "color": "ededed",
        "default": false,
        "id": 1579077344,
        "name": "automated pr",
        "node_id": "MDU6TGFiZWwxNTc5MDc3MzQ0",
        "url": ""
        "color": "ededed",
        "default": false,
        "id": 1441562142,
        "name": "report",
        "node_id": "MDU6TGFiZWwxNDQxNTYyMTQy",
        "url": ""
Copilot Lvl 3
Message 3 of 3

Re: Labeled action on pull_request

Thanks... I've been trying so hard to loop it as is but to no avail. Do I have to run toJSON() to be able to interact with it? Even the normal bash syntax to access the values such as `array[0]` prints `Array[0]`.