Skip to content

Instantly share code, notes, and snippets.

@alexellis
Last active February 23, 2024 02:51
Show Gist options
  • Save alexellis/d8f319a0f9f804ee327df727eef70cd0 to your computer and use it in GitHub Desktop.
Save alexellis/d8f319a0f9f804ee327df727eef70cd0 to your computer and use it in GitHub Desktop.
Insiders Exclusive - Explore and debug GitHub Actions via SSH

Insiders Exclusive - Explore and debug GitHub Actions via SSH

Thanks for offering to help me test out using GitHub Sponsors as an authentication method for the SSH gateway we built for GitHub Actions.

Instructions

This should take < 5 minutes.

Create a new repo in your personal user account.

Add the following file: .github/workflows/connect.yaml:

name: connect

on:
  pull_request:
    branches:
      - '*'
  push:
    branches:
      - master
      - main

  workflow_dispatch:

permissions:
  id-token: write
  contents: read
  actions: read

jobs:
  connect:
    name: connect
    runs-on: ubuntu-latest
    steps:
      - uses: self-actuated/connect-ssh@master

Commit the file and navigate to the sessions page

Look for your connection and SSH command and copy/paste it into a terminal.

Port-forward HTTP and TCP services from the runner

Either have a step in the job that starts a server/daemon, or connect via SSH and start Nginx:

docker run --name nginx -p 8080:80 -d nginx:latest

Next, edit the SSH command given to you, and add:

-L 8080:127.0.0.1:8080

Head over to: http://127.0.0.1:8080 and you'll be accessing the server directly from within the runner.

To forward multiple services:

-L 3000:127.0.0.1:3000 -L 9090:127.0.0.1:9090

And so forth.

Browse the web via GitHub Actions

Connect via SSH using port forwarding as per above:

-L 3128:127.0.0.1:3128

Install Squid:

sudo apt install -qy squid

Make a curl request and see that you have the public IP of the GitHub Actions runner:

curl -x http://127.0.0.1:3128 -i https://checkip.amazonaws.com
HTTP/1.1 200 Connection established

HTTP/1.1 200 OK
Date: Thu, 21 Dec 2023 12:24:18 GMT
Server: Not Available
Content-Length: 12
Connection: keep-alive

4.227.115.6

Try out the CLI

The CLI has an "ssh connect" command to make the above quicker/easier.

You'll need arkade, or to download the binary for actuated-cli from its releases page.

arkade get actuated-cli

actuated-cli auth

actuated-cli ssh list

actuated-cli ssh connect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment