How to exit successfully from custom action

I’m working to create an action which I plan to publish to the GitHub Marketplace that will serve static files on a localhost port for use by future steps within a job. The way this would be incorporated into a workflow would be like this (high-level steps):

  1. Generate files to be served
  2. Use serve-static-action to serve the files on a specific port
  3. Access files on that port

When I run my action, it never exits successfully. You can see where it’s hanging here.

I assume the issue is that the server.listen(portNum) line never returns so my workflow just hangs on that line. How can I have my action complete (successfully) and allow for my the server I create in my action to listen for requests from future steps in the job?

Service containers might be what folks would be looking for About service containers - GitHub Docs

In general, if the process doesn’t exit, actions would be blocked on that. Actions merely runs scripts you provide.

Thank you!

1 Like

Potentially related: How to run a command in background in Windows GitHub Action

It shows how to run a webserver in the background on a Windows runner using a Batch script and the start command. You can probably do something similar under Linux, by appending an ampersand to a command (at least in Bash shells) or with the screen command I suppose.