DEV Community

0 seconds of 0 secondsVolume 90%
Press shift question mark to access a list of keyboard shortcuts
00:00
00:00
00:00
 
Brian Douglas for GitHub

Posted on • Edited on

14 3

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 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@v4
    - 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

Manually triggered debug

Instead of having to add/remove, or uncomment the required config and push commits each time you want to run your workflow with debug…

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_TOKEN's.

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.

Heroku

Deploy with ease. Manage efficiently. Scale faster.

Leave the infrastructure headaches to us, while you focus on pushing boundaries, realizing your vision, and making a lasting impression on your users.

Get Started

Top comments (0)

Billboard image

Try REST API Generation for MS SQL Server.

DevOps for Private APIs. With DreamFactory API Generation, you get:

  • Auto-generated live APIs mapped from database schema
  • Interactive Swagger API documentation
  • Scripting engine to customize your API
  • Built-in role-based access control

Learn more

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay