$ show JamesIves/github-pages-deploy-action
This repository implements a GitHub Action that automates deployment of static content to GitHub Pages. It takes a folder from the workspace, optionally builds it, and pushes the contents to a specified branch (default `gh-pages`) using git worktrees and rsync. The action supports authentication via GitHub token, personal access token, or SSH deploy keys, and offers extensive configuration options including clean deployments, single-commit history, target subfolders, dry runs, tags, and Git LFS. The architecture is modular: `src/main.ts` is the entry point, `src/lib.ts` orchestrates the workflow, `src/git.ts` handles repository initialization and deployment, `src/worktree.ts` manages git worktree creation with retry logic, `src/ssh.ts` configures SSH clients, and `src/execute.ts` provides a reusable command execution wrapper. The action relies on external tools `git`, `rsync`, and `ssh-agent`, and uses the `@actions/*` toolkit for GitHub Actions integration. The codebase is well-structured TypeScript with comprehensive unit and integration tests, and follows modern JavaScript practices with ESLint, Prettier, and Jest.
The LLM identified 2 files worth highlighting for reuse:
A thin wrapper around `@actions/exec` that captures stdout and stderr into a buffer, with automatic truncation at `buffer.constants.MAX_STRING_LENGTH` to prevent memory issues. It exposes a simple `execute(cmd, cwd, silent, ignoreReturnCode)` async function that returns `{stdout, stderr}`. This pattern is reusable in any GitHub Action that needs to run shell commands and inspect their output, and it cleanly separates the execution concern from business logic.
Manages creation of a git worktree for deployment, with robust retry logic when checkout fails due to branch name collisions. It defines a `GitCheckout` class that builds the correct `git checkout` command (orphan vs. non-orphan, with optional commitish). On failure, it falls back to a timestamped branch name while preserving the orphan intent. This pattern demonstrates non-obvious skill in handling edge cases in git operations and can be extracted for any project needing reliable worktree-based deployments.