• Stars
    star
    2,923
  • Rank 15,508 (Top 0.4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 5 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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@v3
    - name: Setup tmate session
      uses: mxschmitt/action-tmate@v3

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, you can make the debug step conditional on an optional parameter that you provide through a workflow_dispatch "manual event".

Add the following to the on events of your workflow:

on:
  workflow_dispatch:
    inputs:
      debug_enabled:
        type: boolean
        description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
        required: false
        default: false

Then add an if condition to the debug step:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      # Enable tmate debugging of manually-triggered workflows if the input option was provided
      - name: Setup tmate session
        uses: mxschmitt/action-tmate@v3
        if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}

You can then manually run a workflow on the desired branch and set debug_enabled to true to get a debug session.

Detached mode

By default, this Action starts a tmate session and waits for the session to be done (typically by way of a user connecting and exiting the shell after debugging). In detached mode, this Action will start the tmate session, print the connection details, and continue with the next step(s) of the workflow's job. At the end of the job, the Action will wait for the session to exit.

name: CI
on: [push]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: Setup tmate session
      uses: mxschmitt/action-tmate@v3
      with:
        detached: true

By default, this mode will wait at the end of the job for a user to connect and then to terminate the tmate session. If no user has connected within 10 minutes after the post-job step started, it will terminate the tmate session and quit gracefully.

Without sudo

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

name: CI
on: [push]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: Setup tmate session
      uses: mxschmitt/action-tmate@v3
      with:
        sudo: false

Timeout

By default the tmate session will remain open until the workflow times out. You can specify your own timeout in minutes if you wish to reduce GitHub Actions usage.

name: CI
on: [push]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: Setup tmate session
      uses: mxschmitt/action-tmate@v3
      timeout-minutes: 15

Only on failure

By default a failed step will cause all following steps to be skipped. You can specify that the tmate session only starts if a previous step failed.

name: CI
on: [push]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: Setup tmate session
      if: ${{ failure() }}
      uses: mxschmitt/action-tmate@v3

Use registered public SSH key(s)

If you have registered one or more public SSH keys with your GitHub profile, tmate will be started such that only those keys are authorized to connect, otherwise anybody can connect to the tmate session. If you want to require a public SSH key to be installed with the tmate session, no matter whether the user who started the workflow has registered any in their GitHub profile, you will need to configure the setting limit-access-to-actor to true, like so:

name: CI
on: [push]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: Setup tmate session
      uses: mxschmitt/action-tmate@v3
      with:
        limit-access-to-actor: true

If the registered public SSH key is not your default private SSH key, you will need to specify the path manually, like so: ssh -i <path-to-key> <tmate-connection-string>.

Use your own tmate servers

By default the tmate session uses ssh.tmate.io. You can use your own tmate servers. tmate-ssh-server is the server side part of tmate.

name: CI
on: [push]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: Setup tmate session
      uses: mxschmitt/action-tmate@v3
      with:
        tmate-server-host: ssh.tmate.io
        tmate-server-port: 22
        tmate-server-rsa-fingerprint: SHA256:Hthk2T/M/Ivqfk1YYUn5ijC2Att3+UPzD7Rn72P5VWs
        tmate-server-ed25519-fingerprint: SHA256:jfttvoypkHiQYUqUCwKeqd9d1fJj/ZiQlFOHVl6E9sI

Skip installing tmate

By default, tmate and its dependencies are installed in a platform-dependent manner. When using self-hosted agents, this can become unnecessary or can even break. You can skip installing tmate and its dependencies using install-dependencies:

name: CI
on: [push]
jobs:
  build:
    runs-on: [self-hosted, linux]
    steps:
    - uses: mxschmitt/action-tmate@v3
      with:
        install-dependencies: false

Continue a workflow

If you want to continue a workflow and you are inside a tmate session, just create a empty file with the name continue either in the root directory or in the project directory by running touch continue or sudo touch /continue.

Connection string / URL is not visible

The connection string will be written in the logs every 5 seconds. For more information checkout issue #1.

More Repositories

1

awesome-playwright

A curated list of awesome tools, utils and projects using Playwright
458
star
2

golang-url-shortener

URL Shortener written in Golang using Bolt DB or Redis. Provides features such as Deletion, Expiration, OAuth and is of course Dockerizable.
Go
283
star
3

try-playwright

Try Playwright lets you execute and share Playwright scripts in your browser to get started with Playwright.
TypeScript
138
star
4

golang-combinations

Golang library which provide an algorithm to generate all combinations out of a given string array.
Go
113
star
5

playwright-test-coverage

Playwright Test (@playwright/test) demo to collect coverage information via Istanbul
TypeScript
107
star
6

python-django-playwright

Example how to use Playwright in combination with Django.
Python
22
star
7

react-have-i-been-pwned

React component for: Have I Been Pwned?
JavaScript
14
star
8

pytest-playwright

Pytest plugin to write Playwright tests with ease. Provides fixtures to have a page instance for each individual test and helpful CLI options for headless browsers.
Python
14
star
9

chrome-odata-viewer

Displays UI5 OData network requests and response payload in a beautified clickable way.
JavaScript
13
star
10

YoutubeWebinterface

JavaScript based graphical YouTube Search Webinterface for the SinusBot.
JavaScript
8
star
11

actions-cheat-sheet

GitHub Actions cheat sheet with some common snippets
7
star
12

playwright-windows-containers

Run Playwright inside Windows Docker containers
TypeScript
6
star
13

connect-to-me

Small summary page for relevant social media profiles.
HTML
5
star
14

golang-hetzner-robot-metrics

Hetzner Robot Price statistics and alerting via Prometheus and Grafana.
Go
5
star
15

DotnetConfDemoTest0947

C#
3
star
16

jump-back-to-1970

3
star
17

golang-env-struct

This package does apply if set the environment variable by a given name from the struct tag to the given struct.
Go
3
star
18

declare-fields-class-properties-compatiblity

TypeScript
2
star
19

testpwdev

HTML
2
star
20

golang-tdd-example

Test driven development in Golang based on Martin Fowlers stack example.
Go
2
star
21

playwright-runner-root-cause-demo

This example shows the usage with Testim Root Cause and the playwright-runner project.
TypeScript
2
star
22

playwright-webview2-demo

Using Playwright in JS/TS/Java/.NET/Java to automate a WebView2 control
TypeScript
2
star
23

azure-container-apps-playwright-demo

Azure Container Apps Playwright example.
HTML
2
star
24

azure-dev-day2

TypeScript
2
star
25

dotnet-batch-childprocess-adds-bom

C#
1
star
26

my-awesome-project

TypeScript
1
star
27

razor-playwright-dotnet-example

HTML
1
star
28

mxschmitt

1
star
29

pwreprotest123

TypeScript
1
star
30

firefox-github-actions-container

TypeScript
1
star
31

discord-happy-hour-demo

TypeScript
1
star
32

vscode-postscript

PostScript Language implementation into VS Code
1
star
33

1506

TypeScript
1
star
34

playwright-docs

Generated Playwright documentations via TypeDoc
1
star
35

client-certificates-with-playwright-demo

TypeScript
1
star
36

Playwright_screenshot_traceback

https://github.com/microsoft/playwright/issues/28098
HTML
1
star
37

playwright-jest-example

Example how to use Playwright in combination with Jest.
JavaScript
1
star
38

github-actions-console-chunking

JavaScript
1
star
39

dotfiles

Shell
1
star
40

python-rpi-alarm

Vue.js application with which you can control an alarm clock via your Raspberry PI.
Python
1
star
41

playwright-driver

Centralized Playwright RPC driver
1
star
42

playwright-azure-sharding

TypeScript
1
star
43

playwright-issue-28595

JavaScript
1
star