Visualizing the github object

I come from JS development and I have a habit of digging, inside the dev tools, into objects to see their props and methods, so that I could use them for whatever functionality I wanted to create.

In GHActions, I understood that there is this workflow context object github, which encompasses everything that happens like events, repo data etc.

Currently, I am trying to create a logic for some of the steps inside a workflow and I would like to if I can base it on information the github object can provide.

Is there any, hopefully as straightforward as objects in dev tools, way to visualize and rummage through the whole github object, optimally in real time ?

I know that this likely doesn’t answer your question, but I am not aware of such tool existing, but you can always write a small node script which logs it out. Probably you could also utilise Github’s toolkit for that:

On the other hand documentation on the context is rather solid, and we rarely had to dig into internals to find out what it’s composed from:

Maybe you could describe your usecase a bit better?

How would you go about doing this ? - “small node script which logs it out”

So far, sounds like this would solve my conundrum, the best.

As far as particular usecase, I was thinking more in general, but currently I am trying to solve this and couldn’t figure it out using the docs myself:

So as I mentioned above you can use actions/toolkit to access github context in node, that’s one way:

Then to make this even more lo-key investment and don’t do bundling you could use acitons/github-script to access toolkit inline inside yaml, as you can see both github and context are parts of the arguments:

When it comes to your specific usecase, I believe you need an “if” with particular assertions agaist
github.head_ref which represents the “source” of PR and github.base_ref which represents the target.

Docs on “if”:

You might also want to have a look at available functions for expressions inside “if” statements, in this case contains seems to be appropriate:

1 Like