nektos / act

Run your GitHub Actions locally 🚀
https://nektosact.com
MIT License
54.49k stars 1.36k forks source link

Add an additional argument `--shell` to open an act generated docker container #2090

Open wolfiex opened 11 months ago

wolfiex commented 11 months ago

Act version

0.2.53

Feature description

When developing actions, it is often useful to explore the final state of the repository. For this using the interactive shell provides a suitable debug tool.

Currently this can be done using the commands outlined below.

Although already possible, there is no reason it should not be attached to the end of the act pipeline with a suggested --shell argument.

# list all the containers, and identify the relevant one
docker ps -a

# launch an interactive shell using the container id
docker exec -it <container_id> /usr/bin/bash
jpivarski commented 8 months ago

+1 to this! The reason I installed act was because I thought it did this. Running GitHub Actions locally is nice—I can avoid the time spent waiting for a runner to launch—but I still need to wait for the initial (installation) steps to complete before reaching the step that I need to debug.

If there were an option to tell act to run the action and save a new Docker image at the point where the action failed, that would be ideal. (Saving a Docker image after success could be useful, too: I could remove the failing step and try commands interactively to determine what that step ought to be, for run steps, anyway.)

I have tried the various alternatives that provide ssh access into a GitHub Action, but not with any success. With one of these (I can't remember which), I managed to connect but couldn't solve the problem before the connection timed out. Naturally, the timeout is for security reasons, but that's why debugging it locally would be an advantage.

robert-smith-maersk commented 4 months ago

Also, the command in the summary only gets you a new shell on the running image and some state is lost (environment variables etc.). It would be even better if act would leave the terminal session in which the workflow is run open and drop us into that...

SaswatPadhi commented 1 week ago

Having such a flag would be nice.

This is what I currently do:

act -W .github/workflows/build.yml || docker exec -it `docker ps -q | head -n1` bash

If the build fails (||) then docker exec into the latest container and run bash.