mxschmitt / action-tmate

Debug your GitHub Actions via SSH by using tmate to get access to the runner system itself.
https://mxschmitt.github.io/action-tmate/
MIT License
2.87k stars 285 forks source link

Is there a way to start tmate in the background? #102

Closed Fgerthoffert closed 2 years ago

Fgerthoffert commented 2 years ago

Hi,

If I understand the readme/doc correctly, with the current behavior, tmate will pause further execution of the workflow until a continue file is created. Or if the action is configured to be enabled on the failure of a previous step, it will stay active until the timeout is reached.

Would it be feasible to somewhat reverse this behavior and configure a workflow in this fashion:

name: CI
on: [push]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Setup tmate session
      uses: mxschmitt/action-tmate@v3
    - [...] Any other steps needed
    - name: Keep tmate session alive
      uses: mxschmitt/action-tmate-alive@v3

In the workflow, the tmate session would always be created and would always be available for incoming connection during the entire job runtime, the tmate session would shut down alongside the runner at the end of the job execution.

If there is a need for debugging, it would be possible to drop a debug file on the filesystem, which would keep the hypothetical action-tmate-alive active while the debug file is present (+ eventually with a timeout).

If that sounds like a feasible approach, I'd be happy to give a shot at submitting a PR.