Repository navigation
Replies: 2 comments
|
-e supplies github.event, but it does not create a real issue in GitHub. Your action then calls octokit.rest.issues.get, which is a network API call against the repository from github.context; if the event points to a fake/nonexistent issue or act's default repository, GitHub correctly returns not found. Use a webhook-shaped event file and set the repository/token explicitly: If the workflow only needs the triggering data, do not re-fetch it: read github.context.payload.issue (or github.event.issue in YAML) and unit-test the label-selection function with fixtures. If you deliberately call issues.get, number 123 must actually exist in OWNER/repo and the token must have access. Also pass the event name explicitly. Without act issues, act may plan a different trigger even though an event JSON file is present. The -e flag only defines GITHUB_EVENT_PATH; it does not infer or materialize GitHub resources. |
|
// event.json
{
"action": "opened",
"issue": {
"number": 1,
"title": "Bug: app crashes on login",
"body": "Steps to reproduce..."
}
}Then: act issues -e event.jsonThat populated — |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hello, I created a GitHub workflow that automatically assigns a label to an issue based on its title and description after the issue is created or edited.
To test this workflow locally, I struggled a lot because using a test repository wasn't very convenient. I found this tool that helps run GitHub Actions workflows locally.
The problem is that my workflow requires the issue creation event to extract the title and labels from the issue and based on these two parameters assigns a label to the issue from the repo available labels.
To simulate this, I created a JSON file with an actual issue object from my test repository and provided it to the act command using the -e flag for a scenario like this:
act -W .github/workflows/issue-created.yml -e scenarios/create-issue-event.jsonHowever, when the workflow runs locally, I encounter an error stating that the issue does not exist, or every field of the issue is
undefined:Could anyone suggest why this might be happening? Am I missing something in the setup, or is there another way to simulate an issue context for testing? Thank you for any help!
All reactions