action-tmate icon indicating copy to clipboard operation
action-tmate copied to clipboard

Continue running the workflow *AND* keep session open

Open jessehouwing opened this issue 2 years ago • 6 comments

It would be nice when the action would spin up the ssh session and would leave the session open to the end of the workflow so you can follow along with top or dump a process that hangs at some point. I haven't dug too deeply into this action... but it would be something nice to do.

jessehouwing avatar Mar 11 '22 08:03 jessehouwing

Seems like it already works that way to me?

garethsb avatar Apr 25 '22 16:04 garethsb

https://github.com/mxschmitt/action-tmate/blob/master/src/index.js#L136

jessehouwing avatar Apr 25 '22 17:04 jessehouwing

We can still keep using a tmate session made by this point until the whole job is finished. What doesn't work?

garethsb avatar Apr 25 '22 17:04 garethsb

Here's a solution I've found. My workflow looks like this:

- run: sudo touch /continue

- name: Open SSH session
  uses: mxschmitt/action-tmate@v3

- (actual workflow steps here...)

- name: Block to allow introspection of failures
  run: sleep infinity

This opens the SSH session, but since the continue file already exists, it will immediately continue to the rest of the workflow. I put in the last step so that when a step fails, the workflow doesn't end - so I can use the SSH shell to debug.

Now, if only this action had built-in support for this...

barrettj12 avatar May 16 '22 06:05 barrettj12

Nice! Yeah, that's what I hacked together in a very similar action:

https://github.com/jessehouwing/debug-via-ssh

It has a terminate file as well you can touch to end the session, otherwise, it will remain open.

I've actually snuck that into a post-job to be able to debug those as well.

It's not pretty, but it works for now.

For some reason I've had quite a few issues getting t-mate to work in certain places, so I switched to another ssh solution for now, this action is much prettier in most other things though.

jessehouwing avatar May 16 '22 07:05 jessehouwing

Nice! Yeah, that's what I hacked together in a very similar action:

Thanks for providing this! It's quite a neat tool.

dejayc avatar Feb 13 '23 01:02 dejayc