mirror of
https://github.com/nektos/act.git
synced 2026-04-26 01:15:51 +03:00
[GH-ISSUE #1401] Event details not loaded from JSON file provided via --eventpath param #739
Labels
No labels
area/action
area/cli
area/docs
area/image
area/runner
area/workflow
backlog
confirmed/not-planned
kind/bug
kind/discussion
kind/external
kind/feature-request
kind/question
meta/duplicate
meta/invalid
meta/need-more-info
meta/resolved
meta/wontfix
meta/workaround
needs-work
pull-request
review/not-planned
size/M
size/XL
size/XXL
stale
stale-exempt
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/act#739
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @cweckesser on GitHub (Oct 19, 2022).
Original GitHub issue: https://github.com/nektos/act/issues/1401
Setup
Operating system:
macOS Monterey v12.6Act version:
0.2.32Issue
The
actcommand doesn't seem to read the contents of the GH event JSON file provided via the CLI parameter--eventpath.In particular, the event name, the head ref and the base ref do not get read from the event JSON file. Possibly some other values might not be read either, but I haven't gotten that far.
Expected result
The values for the event name, the head ref and the base ref should be read from the event JSON file. Ideally, this should also apply to any other values specified in the file, conforming with GitHub's event properties).
How to reproduce
1. Executed the command
2. Provide content of the event file (
my-custom-event.json)3. Verify environment setup in the command's output
Expand (collapsed due to verbosity of output)
References:
(1) GH base ref not read from file! Expected value -> "main"
(2) GH event name not read from file and defaulted to "push"
(3) GH head ref not read from file! Expected value -> "my-topic-branch"
(4) GH ref not read from file! Expected value -> "my-topic-branch"
Further symptoms of the issue
One of the steps of the workflow needs to only run when building the "main" branch after a "push" event. The event file specifies the "my-topic-branch" branch and the "pull_request" event, but then the following check succeeds when it should fail:
Related issues
https://github.com/nektos/act/issues/671
@KnisterPeter commented on GitHub (Oct 19, 2022):
Please read this
https://github.com/nektos/act#example-commands
@ChristopherHX commented on GitHub (Oct 19, 2022):
Event name is not part of a webhook payload, it is part of http headers.
All what can be done is guessing, especially if the user omit properties. In your example it is impossible to distinguish pull_request from pull_request_target etc..
You are supposed to call
act pull_request ...I agree, the other values could be mapped.
@cweckesser commented on GitHub (Oct 20, 2022):
@ChristopherHX If it is ok with you, I can open another issue just referring to head ref and base ref values from the file not being mapped.
@ChristopherHX commented on GitHub (Oct 20, 2022):
No head ref and base ref is working
github.com/nektos/act@41b03b581c/pkg/runner/testdata/pull-request/main.yamland has a Test.It is even explained in the ReadMe file. The push trigger don't have a value for head ref and base ref, but that's expected.
@cweckesser commented on GitHub (Oct 20, 2022):
@ChristopherHX Are you saying that the mapping of head ref and base ref from the file specified via
--eventpathis working? I don't see that reflected in what Act logs, when running in verbose mode.The command I'm running is:
And my
event.jsonfile is:But then, Act logs this:
You can see that
GITHUB_BASE_REFandGITHUB_HEAD_REFare empty, so they are not being mapped.Notice that I'm NOT using the push trigger. I'm actually using the pull_request trigger and I'm using the same structure for the event JSON file as the one provided by the Act docs.
@ChristopherHX commented on GitHub (Oct 20, 2022):
Yes I say it is working and I have no idea why it shouldn't work for you.
I can see this on my computer and in the actions checks on github:
I used the latest release from the releases page
act.exe pull_request -W w.yml -e ev.jsonworkflow:
ev.json is your json file
@cweckesser commented on GitHub (Oct 20, 2022):
@ChristopherHX I really appreciate you taking the time to see into this.
I think I managed now to reproduce why I can't access the
github.head_refandgithub.head_refvariables.The workflow and action I was testing with were quite lengthy and complex, so I tried to reproduce the issue with a more simplified version of it. In my case, I have reusable workflows and actions called from within the main workflow. Since Act explicitly doesn't support reusable workflows, the new attempt to reproduce the issue includes only actions called from within a workflow.
Issue
It looks like Act does not propagate these values from a workflow to an action used within it.
How to reproduce
You can see in the output that the action invoked from the workflow cannot access the
github.head_refandgithub.head_refvariables.@ChristopherHX commented on GitHub (Oct 20, 2022):
I guess the whole github.event is blank in the composite actions?
EventJSON is discarded here:
github.com/nektos/act@bc17371017/pkg/runner/action_composite.go (L52-L72)I didn't refactor composite actions, it is possible that this bug is not present act v0.2.25.
@cweckesser commented on GitHub (Oct 20, 2022):
Thank you very much again @ChristopherHX!