action-tmate
action-tmate copied to clipboard
Continue running the workflow *AND* keep session open
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.
Seems like it already works that way to me?
https://github.com/mxschmitt/action-tmate/blob/master/src/index.js#L136
We can still keep using a tmate session made by this point until the whole job is finished. What doesn't work?
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...
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.
Nice! Yeah, that's what I hacked together in a very similar action:
Thanks for providing this! It's quite a neat tool.