How to get the title of a Pull Request with Github Actions

Viewed 2812

In GitHub I have a pull request called [WIP] Dev-123 Sample Pull Request.

I want to get this title in a GitHub Actions yaml pipeline.

In the GitHub Docs Context I can't seem to find which object I need to reference.

1 Answers

The title of the Pull Request can be accessed by github.event.pull_request.title

The workflow to use this would be:

on:
  push:
  pull_request:
   types: [opened, synchronize]

  print_title_of_pr:
    runs-on: ubuntu-20.04
    steps:
    - name : Print Title of PR
      run: echo The Title of your PR is ${{ github.event.pull_request.title }}
Related