Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 216
steve238 Avatar asked Sep 01 '25 22:09

steve238


1 Answers

This answer is functionally correct but has a security risk of script injection, see Yaron Avital's answer for the way recommended by GitHub

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 }}
like image 142
steve238 Avatar answered Sep 03 '25 17:09

steve238