Debug your GitHub Actions via SSH by using tmate

I spend most of my time developing on the front ends that host on cloud environments. Most of these projects do not require me to ever inspect servers things as they just kind of work, which is nice.

From my understanding, tmate is a tool that provide…


This content originally appeared on DEV Community and was authored by Brian Douglas

I spend most of my time developing on the front ends that host on cloud environments. Most of these projects do not require me to ever inspect servers things as they just kind of work, which is nice.

From my understanding, tmate is a tool that provides instant terminal sharing. You're able to activate a secure shell or SSH to explore and run commands. I perform a lot of my debugging with action-tmate to access the hosted runner environments.

GitHub logo mxschmitt / action-tmate

Debug your GitHub Actions via SSH by using tmate to get access to the runner system itself.

Debug your GitHub Actions by using tmate

GitHub Actions GitHub Marketplace

This GitHub Action offers you a direct way to interact with the host system on which the actual scripts (Actions) will run.

Features

  • Debug your GitHub Actions by using SSH or Web shell
  • Continue your Workflows afterwards

Supported Operating Systems

  • Linux
  • macOS
  • Windows

Getting Started

By using this minimal example a tmate session will be created.

name: CI
on: [push]
jobs
  build
    runs-on: ubuntu-latest
    steps
    - uses: actions/checkout@v2
    - name: Setup tmate session
      uses: mxschmitt/action-tmate@v3
Enter fullscreen mode Exit fullscreen mode

To get the connection string, just open the Checks tab in your Pull Request and scroll to the bottom. There you can connect either directly per SSH or via a web based terminal.

GitHub Checks tab

Without sudo

By default we run the commands using sudo. If you get sudo: not found you can use the parameter below to execute the commands…

To do this, I paste the action directly into my workflows using the mxschmitt/action-tmate repo.

name: CI
on: [push]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Setup tmate session
      uses: mxschmitt/action-tmate@v3
Enter fullscreen mode Exit fullscreen mode

It takes a few seconds for a tmate to provide the URL, but when it does, I can start navigating the environment.

In the gif, you can see the I have a fully running environment for me to test out.

So if you find yourself stuck and seeing some weirdness in your workflows, consider opening a tmate session and sharing with coworkers. Just keep in mind that you are running a live session that uses action minutes and has access to any used GITHUB_TOKENS.

This is part of my 28 days of Actions series. To get notified of more GitHub Action tips, follow the GitHub organization right here on Dev.


This content originally appeared on DEV Community and was authored by Brian Douglas


Print Share Comment Cite Upload Translate Updates
APA

Brian Douglas | Sciencx (2021-02-12T21:44:15+00:00) Debug your GitHub Actions via SSH by using tmate. Retrieved from https://www.scien.cx/2021/02/12/debug-your-github-actions-via-ssh-by-using-tmate/

MLA
" » Debug your GitHub Actions via SSH by using tmate." Brian Douglas | Sciencx - Friday February 12, 2021, https://www.scien.cx/2021/02/12/debug-your-github-actions-via-ssh-by-using-tmate/
HARVARD
Brian Douglas | Sciencx Friday February 12, 2021 » Debug your GitHub Actions via SSH by using tmate., viewed ,<https://www.scien.cx/2021/02/12/debug-your-github-actions-via-ssh-by-using-tmate/>
VANCOUVER
Brian Douglas | Sciencx - » Debug your GitHub Actions via SSH by using tmate. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/02/12/debug-your-github-actions-via-ssh-by-using-tmate/
CHICAGO
" » Debug your GitHub Actions via SSH by using tmate." Brian Douglas | Sciencx - Accessed . https://www.scien.cx/2021/02/12/debug-your-github-actions-via-ssh-by-using-tmate/
IEEE
" » Debug your GitHub Actions via SSH by using tmate." Brian Douglas | Sciencx [Online]. Available: https://www.scien.cx/2021/02/12/debug-your-github-actions-via-ssh-by-using-tmate/. [Accessed: ]
rf:citation
» Debug your GitHub Actions via SSH by using tmate | Brian Douglas | Sciencx | https://www.scien.cx/2021/02/12/debug-your-github-actions-via-ssh-by-using-tmate/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.