Accessing GH context in actions

Is there anyway to access the GH context from within an action, without having to specify e.g. env og secrets as inputs for the action? Right now I serialize e.g. secrets as a parameter for the action and deserialize within the action.

Thoughts?

Can anyone confirm that accessing GH context is not possible within an action, without specifying it as a parameter input?

I don’t think it’s currently possible to access the context directly.

Consider github-script, which provides a partial context containing some of the items from the workflow github context. That partial context is actually just rehydrated from the environment. If it were possible to get the real context directly it would make sense for github-script to do that. The fact it doesn’t suggests it’s not possible.

One workaround is to add inputs to your action, but set the default using the context, eg:

That’s ok if it makes sense to give users of the action the option to override the default value.

1 Like

That’s a pretty good idea and letting the user option out by overriding the inputs makes perfectly sense. In my case I need access to both the github and secrets context for setting up variables based on the environment context in the json-variables action. The default assignment makes usage syntax far more clean, while still being able to overwrite.
Thanks!