Could I get issue title in Github actions by environment variables?

Hi I’m trying to get issue title to use it to create issue clone on an another service.

If it’s possible I’d like to get issue title in yml like getting branch name ?

1 Like

Hi @KouWakai
unfortunately, there is no that variable.
You can check what are in place Environment variables - GitHub Docs.
Also you can try to check GH marketplace GitHub Marketplace · Actions to improve your workflow · GitHub maybe some actions can help you to achieve your goals.

1 Like

Depending on the event, it’s possible that what you want is available in the event objects which can be mapped to environment variables using ${{...}} magic.

You could try using toJSON(...) on each of the contexts in a step to see what’s available.

2 Likes

Yes, @jsoref is right there.

It’s not exactly env var and not for all GH events, but in this way you could access some context for few events.

If to use events eg issues Events that trigger workflows - GitHub Docs or issue_comment Events that trigger workflows - GitHub Docs some information will be inside payload, for example for issues Webhook events and payloads - GitHub Docs.
Then inside ${{ github.event.issue.title }} will be title of issue that triggered event.

@KouWakai you can check this Get contents/body of issue in action as well

1 Like

This one is self resolved.

There is no way to get issue title like I asked.

We could get title from payload which comes from @actions/github

like this:

const github = require(’@actions/github’);


    // Get context and payload
    const context = github.context;
    const payload = context.payload;

    if (payload.issue && payload.issue.title) {
      return payload.issue.title;
    }

@ViacheslavKudinov @jsoref

Thank you for helping me out:pray:

I couldn’t see reply yesterday for some reason(maybe the replies are meant to be awaiting for approval?)

I’ll check toJSON(...) out.