Access events object or commit history from JS actions

I’m trying to build a github action using JavaScript. My action wants to access list of commits included in a push.

I can achieve this (when not using JavaScript action) by following command:

git rev-list {{ github.event.before }}..{{ github.event.after }}

Now problem is that I cannot find away to access these github.event.before variable from JavaScript action. It doesn’t seem like @actions/github npm package doesn’t expose it. Only way I could think of is asking users of my action to populate this and pass it to my action but I want to avoid it to make integration simple.

Is there a way for JavaScript action to access this raw event object?

:wave: Hey @daisy1754,

The full event info can be found in a JSON file located with the GITHUB_EVENT_PATH environment variable. Your action should be able to load that file and get any information it needs.

1 Like