Skip to content

ibrews/gh-wiki-init

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gh-wiki-init

Enable and initialize a GitHub repository's wiki from the terminal — including the "Create the first page" step that normally forces you into the browser. A gh extension, and the wiki sibling of gh-social-upload.

gh extension install ibrews/gh-wiki-init
gh wiki-init init-auth                          # one-time browser login
gh wiki-init OWNER/REPO ./my-wiki-pages          # enable + create first page + push pages

Why this exists

Spinning up a repo's wiki from a script is weirdly hard:

  • has_wiki is a repo setting (settable via the API), but the OWNER/REPO.wiki.git repo doesn't exist until a first page is created — until then git clone/git push returns remote: Repository not found, even with has_wiki on. (The "just git push to init it" trick is a myth.)
  • And there is no REST/GraphQL API to create a wiki page. So the first page can only be made by submitting GitHub's web form.

So gh wiki-init does the one unavoidable UI step (drive the new-page form via a saved browser session, à la gh social-upload), then does everything else over plain git. After that, git push to .wiki.git works normally.

Install

gh extension install ibrews/gh-wiki-init
# one-time deps for the browser step:
cd "$(gh extension list | grep gh-wiki-init >/dev/null && dirname "$(gh extension exec wiki-init --help >/dev/null 2>&1; echo)")" 2>/dev/null
# simplest: cd into the extension dir and install
cd ~/.local/share/gh/extensions/gh-wiki-init && npm install && npx playwright install chromium chromium-headless-shell

Then log in once:

gh wiki-init init-auth

A Chromium window opens; log into GitHub (2FA included) and it saves the session and closes itself. The session is stored at ~/.local/state/gh-wiki-init/auth/github.json — and if you already use gh-social-upload, its session is reused automatically, so you don't log in twice.

Usage

# minimal: enable the wiki + create a Home page pointing at the README
gh wiki-init OWNER/REPO

# seed the wiki from a folder of Markdown pages (must contain Home.md; other *.md become pages)
gh wiki-init OWNER/REPO ./wiki-pages

Idempotent: if the wiki already has pages, your pages are merged in (clone → copy → push); if it's empty, the first page is created for you first.

Things to Try

  1. Stand up a wiki in one command. gh wiki-init init-auth once, then gh wiki-init your/repo ./pages — the wiki goes from "doesn't exist" to live, no browser clicking.
  2. Seed real pages. Make a pages/ folder with Home.md, Getting-Started.md, FAQ.md, then gh wiki-init your/repo ./pages — each .md becomes a wiki page (GitHub uses the filename, dashes → spaces).
  3. Use it in CI. After gh wiki-init init-auth on a machine once (session persists for weeks), a job can regenerate wiki pages and gh wiki-init them on every push — no human in the loop.
  4. Re-seed an existing wiki. Point it at a repo whose wiki already exists; it clones, overlays your pages, and pushes — handy for keeping a wiki in sync from a docs folder in your main repo.
  5. Pair it with gh-social-upload. Both automate the GitHub web-UI-only steps (wiki first page / social-preview image). Install both and a fresh repo is "public-ready" from the terminal.

How it works

gh wiki-init OWNER/REPO pages_dir
  │
  ├─ gh api PATCH repos/OWNER/REPO has_wiki=true        (enable the feature)
  ├─ git ls-remote …wiki.git  →  initialized?
  │     └─ no →  Playwright opens …/wiki/_new, fills the gollum form, "Save page"   (first page)
  └─ git clone …wiki.git → copy your pages → git push                              (your pages)

The browser step uses a saved Playwright session (Chromium, headless) and only touches the new-page form. The git steps use your gh auth token.

Notes & limits

  • macOS/Linux (uses gh, git, and Playwright's Chromium).
  • The session can expire (~weeks); if a run reports it's logged out, re-run gh wiki-init init-auth.
  • GitHub's wiki form has anti-spam timing + a honeypot field; the tool waits a beat before submitting and never fills the honeypot.
  • No token is embedded in any committed file; git auth uses gh auth token at run time (and is redacted from error output).

License

MIT © Alex Coulombe. Not affiliated with GitHub.

About

Enable + initialize a GitHub repo's wiki from the terminal — the wiki sibling of gh-social-upload.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors