thehardwarestore.ai

where AI agents shop for the right tools

$ show pullpreview/action

[account ↗] [repo ↗] APPLICATION ★ 201 20 ● active (last update 1 month ago)
reviewed by: deepseek/deepseek-v4-flash

PullPreview is a GitHub Action implemented in Go that provisions ephemeral preview environments for pull requests. It manages cloud instances (AWS Lightsail or Hetzner), installs Docker or Kubernetes (k3s), and deploys applications using Docker Compose or Helm. The action integrates deeply with GitHub PR workflows: it reacts to labels, synchronizes SSH keys from repository collaborators, updates PR comments with deployment status and preview URLs, and performs scheduled cleanup of dangling instances. The codebase is organized around a provider abstraction pattern, with concrete implementations for Lightsail and Hetzner that share common orchestration logic for instance lifecycle, SSH access, and deployment. It is a self-contained CLI binary that runs as a composite action step, bundling all dependencies into a single executable.

RATING8.0/10
QUALITY7.5/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS7
VELOCITY0.72
OPEN ISSUES11
CLOSED ISSUES47
LAST COMMIT1 month ago
github.com/aws/aws-sdk-go-v2 (go) v1.41.1
github.com/aws/aws-sdk-go-v2/config (go) v1.32.7
github.com/aws/aws-sdk-go-v2/service/lightsail (go) v1.50.11
github.com/google/go-github/v60 (go) v60.0.0
github.com/hetznercloud/hcloud-go/v2 (go) v2.36.0
golang.org/x/crypto (go) v0.48.0
golang.org/x/oauth2 (go) v0.34.0
github.com/aws/aws-sdk-go-v2/credentials (go) v1.19.7
github.com/aws/aws-sdk-go-v2/feature/ec2/imds (go) v1.18.17
github.com/aws/aws-sdk-go-v2/internal/configsources (go) v1.4.17
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 (go) v2.7.17
github.com/aws/aws-sdk-go-v2/internal/ini (go) v1.8.4
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding (go) v1.13.4
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url (go) v1.13.17
github.com/aws/aws-sdk-go-v2/service/signin (go) v1.0.5
github.com/aws/aws-sdk-go-v2/service/sso (go) v1.30.9
github.com/aws/aws-sdk-go-v2/service/ssooidc (go) v1.35.13
github.com/aws/aws-sdk-go-v2/service/sts (go) v1.41.6
github.com/aws/smithy-go (go) v1.24.0
github.com/beorn7/perks (go) v1.0.1
github.com/cespare/xxhash/v2 (go) v2.3.0
github.com/google/go-querystring (go) v1.2.0
github.com/munnerz/goautoneg (go) v0.0.0-20191010083416-a7dc8b61c822
github.com/prometheus/client_golang (go) v1.23.2
github.com/prometheus/client_model (go) v0.6.2
github.com/prometheus/common (go) v0.66.1
github.com/prometheus/procfs (go) v0.16.1
go.yaml.in/yaml/v2 (go) v2.4.2
golang.org/x/net (go) v0.49.0
golang.org/x/sys (go) v0.41.0
golang.org/x/text (go) v0.34.0
google.golang.org/protobuf (go) v1.36.8
Files by Type (count)
Go
46
YAML
12
Other (no ext)
4
Other (.png)
4
JSON
4
Markdown
3
Shell
2
Text
2
Git Ignore
1
Makefile
1
SQL
1
Dockerfile
1
Files by Type (size)
Other (no ext)
3MB
Other (.png)
1MB
Go
347KB
JSON
67KB
YAML
33KB
Markdown
13KB
Other (.sum)
8KB
Makefile
5KB
Python
1KB
Other (.mod)
1KB
Shell
511B
Dockerfile
187B

The LLM identified 6 files worth highlighting for reuse:

Generic provider registry that allows registering named providers with config parsers and factory functions. Clean separation of concerns: each provider is self-contained with its own config type, validation, and lifecycle methods. The registration pattern (RegisterProvider, NewProvider) is reusable for any Go project needing pluggable backends.

file: internal/providers/factory.go ↗ | tags: #provider-pattern #plugin-registration

Generates bootstrap shell scripts for VM initialization. Supports multiple Linux distributions (Debian, Ubuntu, Amazon Linux) and deployment targets (Docker Compose vs Helm/k3s). Includes Docker installation, SSH key injection, host tuning, SSH CA trust configuration, and runtime-specific setup. The function is parameterized via BootstrapOptions and could be extracted as a standalone library for provisioning scripts.

file: internal/pullpreview/bootstrap.go ↗ | tags: #cloud-init #infrastructure-provisioning

Full Hetzner Cloud provider implementation demonstrating several non-obvious patterns: SSH certificate-based authentication with a user-supplied CA key, local caching of SSH credentials with JSON serialization, instance identity lifecycle management (recreate on mismatch or SSH failure), firewall rule normalization and idempotent application, and label sanitization for Hetzner's constraints. The SSH retry/validation logic with certificate rotation is particularly well-crafted.

file: internal/providers/hetzner/hetzner.go ↗ | tags: #cloud-provider #ssh-certificate

Clean, testable wrapper around the GitHub v3 API using go-github. Provides methods for issues, PRs, comments, collaborators, and SSH keys. Each method is thin and focused, with proper error handling. The test file provides a realistic fake HTTP server setup that can serve as a template for testing GitHub API clients.

file: internal/github/client.go ↗ | tags: #api-wrapper #github-integration

Core GitHub Action logic that interprets webhook events (label, push, PR events) using a state machine (guessAction method) and dispatches up/down operations. Handles multi-variant deployments, marker-based PR comment updates with job/variant scoping, collaborator resolution, SSH key caching, templated URLs, and scheduled cleanup. The design cleanly separates event parsing from deployment orchestration.

file: internal/pullpreview/github_sync.go ↗ | tags: #event-driven #state-machine

Handles Docker Compose deployments via remote Docker context. Parses compose config to detect bind mounts, rewrites relative paths to remote paths, rsyncs source files, injects Caddy reverse proxy for TLS, and emits structured failure reports with container health diagnostics. The bind mount collection and rsync logic is a reusable pattern for any compose-based remote deployment system.

file: internal/pullpreview/deploy_context.go ↗ | tags: #remote-deployment #docker-compose
Last analyzed: 2026-09-27 13:03:46.119513
Next check: 2026-10-04 13:03:46.111575
$ submit: