GitHub authentication
Let gh and git push over HTTPS authenticate with a GitHub token that you choose, instead of your own credentials.
The token lives in a file on the host. A small gh wrapper reads it on every call, and Git uses gh as its credential helper, so both work in isodev exec, agents, hooks and isodev enter shells, and a replaced token takes effect immediately.
Set up
Use the files in examples/guides/github. The wrapper must be executable; copying the directory keeps its mode, otherwise run chmod +x ~/.config/isodev/bin/gh.
# yaml-language-server: $schema=https://isodev.dyszkiewicz.me/config.schema.json
# gh and git over HTTPS, authenticated with the token in github-token/token.
image: isodev-github:latest
build:
context: image
volumes:
# The directory, not the file, so that a replaced token is visible.
- type: bind
source: github-token
target: /run/secrets/github
read_only: true
# The wrapper that passes the token to gh, ahead of /usr/bin/gh on PATH.
- type: bind
source: bin/gh
target: /usr/local/bin/gh
read_only: trueFROM ubuntu:24.04
ARG DEBIAN_FRONTEND=noninteractive
# mise installs tools to ~/.local/share/mise and puts them on PATH through its
# shims. /usr/local/bin comes first, so files mounted there win.
ENV PATH=/root/.local/bin:/usr/local/sbin:/usr/local/bin:/root/.local/share/mise/shims:/usr/sbin:/usr/bin:/sbin:/bin
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates curl git \
&& rm -rf /var/lib/apt/lists/*
# mise, which installs the tools.
RUN curl -fsSL https://mise.run | MISE_INSTALL_PATH=/usr/local/bin/mise sh
# GitHub CLI, also used by Git as the credential helper for github.com. `gh`
# resolves to the wrapper in /usr/local/bin.
RUN mise use --global gh \
&& git config --system credential.https://github.com.helper '!gh auth git-credential'#!/bin/sh
# Passes the token in /run/secrets/github/token to the real gh. It reads the
# token on every call, so a replaced token takes effect immediately.
set -eu
token=/run/secrets/github/token
if [ ! -s "$token" ]; then
echo "GitHub token missing or empty: $token" >&2
exit 1
fi
GH_TOKEN="$(cat "$token")"
export GH_TOKEN
exec /root/.local/share/mise/shims/gh "$@"The configuration mounts the token’s directory rather than the file: tools that replace the token atomically create a new file, which a single-file mount would not see.
Provide a token
Write the token to ~/.config/isodev/github-token/token, readable only by you:
mkdir -p ~/.config/isodev/github-token
chmod 700 ~/.config/isodev/github-token
cat > ~/.config/isodev/github-token/token # Paste the token, then press Ctrl-D
chmod 600 ~/.config/isodev/github-token/tokenUse it
isodev up --recreate
isodev exec gh auth statusTrade-offs
- Anything in the container can read the token, including agents and the tools they run. Grant it only the repositories and permissions the containers need.