Act: Context unavailable?

Created on 6 Mar 2020  路  13Comments  路  Source: nektos/act

First - wonderful project! I'm tired of pushing hundreds of commits while debugging actions. This will simplify my workflow quite a bit.

One issue I've run into is that the Github context appears to be unavailable within act. Which actually kind of makes sense, given that the actions are not running on Github - but it seems like portions should be easy to shim. Specifically, github.head_ref seems easy to shim in.

Even if this isn't possible, is there a way for me to manually provide the context when calling the action? As a temporary workaround, I moved all references to the github context into the env variables, so it's easy to override when testing locally.

areaction kinbug

All 13 comments

Much of the GitHub context is implemented, however head_ref and base_ref were skipped because I wasn't sure how to implement it...where would i pull those from?

https://github.com/nektos/act/blob/4fde7d88658ba5755add6926c6d5d1bec0e80db8/pkg/runner/run_context.go#L327

Actually - it appears ALL context is unavailable - trying to pull ${{ env.BRANCH }} after setting the env at the top of the file returns undefined. Am I consuming it incorrectly?

env should definitely work...do you have a sample repo you can share?

Actually, i think i should pull those head_ref and base_ref from the event JSON...then you'd just have to provide that file to act

env should definitely work...do you have a sample repo you can share?

Thanks for the quick response @cplee! I can't share a full repo, but here is essentially what I'm running: https://gist.github.com/jacob-israel-turner/5b90ba7a4aaa6d98044581249e957f69

The Log command prints undefined, and from the behavior of other steps later in the job, it appears that the branch provided to Checkout Branch is undefined as well.

I ran this same file on Github and the branch logs and checks out correctly.

Actually, i think i should pull those head_ref and base_ref from the event JSON...then you'd just have to provide that file to act

That would be awesome - I could provide a JSON event when running act pull_request, for example? If there's documentation around this, I think it's a great solution.

dang. you're right, env context has a bug. i was able to reproduce locally

Cool. Thanks for the quick turnaround - let me know if there's anything I can do to help debug!

Would you prefer me to open a new issue re: github.head_ref and github.base_ref?

nah, will squash both 馃悰

fixed on master. will include in next release.

Thanks a ton man! Will there be documentation around how to provide an event.json to act? From reading the code, it looks like just having an event.json file in the working directory might do it. If that's the case, I'm happy to add to the README.

act -h shows the options...to specify an event file use:

act -e my-event.json

would love help with README 馃檹

Just opened two PR's - let me know if you want any changes!

https://github.com/nektos/act/pulls/jacob-israel-turner

Was this page helpful?
0 / 5 - 0 ratings

Related issues

helaili picture helaili  路  4Comments

mheap picture mheap  路  5Comments

Sygmei picture Sygmei  路  3Comments

aaronmeder picture aaronmeder  路  4Comments

ovitente picture ovitente  路  6Comments