Skip to main content

Live tail GitHub Actions runs on git push

Project description

octotail

Live tail GitHub Action runs on git push. It's cursed.

Prerequisites

  • python 3.12
  • a working Chrome-based browser under /usr/bin/chromium

Installation

Clone the repo:

git clone https://github.com/rarescosma/octotail.git
cd octotail

Make a virtual environment, activate it, and install requirements:

python3 -m venv .venv
source .venv/bin/activate
pip3 install -r requirements.txt

Install the package itself:

pip3 install -e .

Make sure /usr/bin/chromium points to a working Chrome-based browser.

If unsure, and on Arch:

paru ungoogled-chromium-bin

Run mitmproxy once and install its root certificate:

mitmproxy
^C

sudo trust anchor ~/.mitmproxy/mitmproxy-ca-cert.cer

Usage

# octotail --help
Usage: octotail [OPTIONS] COMMIT_SHA WORKFLOW

Arguments:
  COMMIT_SHA  [required]
  WORKFLOW    [required]

Options:
  --gh-user TEXT              [env var: _GH_USER; required]
  --gh-pass TEXT              [env var: _GH_PASS; required]
  --gh-otp TEXT               [env var: _GH_OTP; required]
  --gh-pat TEXT               [env var: _GH_PAT; required]
  --headless / --no-headless  [env var: _HEADLESS; default: headless]
  --help                      Show this message and exit.

Will look for an active run for the given <commit_sha> and <workflow> and attempt via skull-crushing voodoo magic to tail its logs.

NOTE: the <commit_sha> has to be of the full 40 characters length.

As a post-receive hook

A slightly more advanced use case that lets you stream the run outputs on git push, similar to how you get the test runs results when pushing to Codecrafters.

For this to work we'll need control over the remote's output, so we can't use the GitHub remote directly. Instead, we'll use a bare repository a our "proxy" remote and set up its post-receive hook to call this cursed script.

cd your-original-repo
export ORIG_REMOTE="$(git remote get-url origin)"
export PROXY_REPO="${HOME}/src/proxy-repo"

git clone --mirror $ORIG_REMOTE $PROXY_REPO
git remote add proxy $PROXY_REPO
# back to octotail
cd -

cp post-receive.sample $PROXY_REPO/hooks/post-receive

Edit $PROXY_REPO/hooks/post-receive and change things according to your setup:

  • set _ACTION_CAT to the path where you actually cloned this repo
  • set _GH_USER to your GitHub username
  • set _GH_PASS_CMD to a command that outputs the GitHub password, e.g. _GH_PASS_CMD="pass github.com"
  • if using 2FA - set _GH_OTP_CMD to a command that outputs an OTP token for the GitHub 2FA, e.g. _GH_OTP_CMD="totp github.com"
  • set _GH_PAT_CMD to a command that outputs your GitHub PAT token, e.g. _GH_PAT_CMD="pass github_pat"
  • set _WORKFLOW to the name of the workflow whose runs you want to tail
  • replace "refs/heads/main" with refs/tags/* (without the quotes) if you expect the workflow to run on tags

NOTE: the hook assumes you're using zsh. You can change the shebang to your own shell, but you might want to invoke it with the right flags to get an interactive, login shell. Useful to get access to custom functions and aliases.

That's it! (phew) - now try pushing some commits to the proxy remote and check if you get the GitHub Actions run logs streaming right back:

cd your-original-repo
git commit --allow-empty -m 'test octotail'
git push proxy

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

octotail-1.0.1.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

octotail-1.0.1-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file octotail-1.0.1.tar.gz.

File metadata

  • Download URL: octotail-1.0.1.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.7 Linux/6.11.2-arch1-1

File hashes

Hashes for octotail-1.0.1.tar.gz
Algorithm Hash digest
SHA256 01f3c0acc7edf0367f5cca04a3a2890bde376b45456373b4b5046fd8a5531762
MD5 e8f117c67a32c99953aa5e7b07d9df81
BLAKE2b-256 7ad71df79b043ea93ccf77d6c72ff32a41bfb7b472a3ef8ccb54f83f789a9613

See more details on using hashes here.

File details

Details for the file octotail-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: octotail-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.7 Linux/6.11.2-arch1-1

File hashes

Hashes for octotail-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 037abd305d36f7e934ea94de67388e5dd9423bf156216db21af8a22f6155ec66
MD5 d29aed321de8d097081c2dfde20fa34e
BLAKE2b-256 9b5d3d4f13a1c826e180ca5511d50c4e1fe34e8e3feb888168850608bb241648

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page