How onee-only/ff-merge works
Project type and purpose
• Type: A GitHub Action packaged as a Dockerized Go application.
• Purpose: Listens for pull_request and issue_comment events on GitHub, validates fast-forward merge conditions, then issues a git merge --ff-only (and optional comment) via the GitHub API.
File structure
• Top-level action files
– action.yml: action metadata, inputs, outputs
– Dockerfile: build image spec
– main.go: entrypoint and orchestration
• Internal packages
– internal/fastforward: core merge logic
– internal/github: GitHub API client, permission checks, comment logic
– internal/types: shared data structures (e.g., event payload wrappers)
• CI/CD
– .github/workflows/build-push-release.yml: build & publish container
• Config
– go.mod/go.sum: dependency management
Extract architecture hints from README
• Supported Events (pull_request, issue_comment)
• Inputs (merge flag, comment policy, allowed-roles, GITHUB_TOKEN)
• Workflow triggers & examples illustrating how the action is invoked
Main components & interactions
a. Event Source: GitHub
– pull_request event
– issue_comment event
b. Runner Environment: GitHub Actions hosted runner
– Pulls container image
– Supplies event payload and inputs as environment vars
c. ff-merge Container (Go application)
1. main.go orchestrator
2. internal/types: parse incoming JSON into typed structs
3. internal/github:
• Authenticate to GitHub using GITHUB_TOKEN
• Fetch PR details & actor permissions
• Decide if fast-forward is allowed
• If allowed & merge input=true → merge PR
• If comment policy requires → post comment
4. internal/fastforward:
• Validate head/tip match
• Construct merge commit if applicable
d. External Service: GitHub API endpoints
– GET pull request info
– POST merge command
– POST comments
e. Outputs: Merge result status, optional comment
Architectural patterns & design principles
• Modular layering
– Separation of concerns: orchestration (main), domain logic (fastforward), API client (github), data types (types)
• Single‐container, event‐driven function
• Immutable inputs → pure functions for decision logic
• Clear boundary: all side‐effects (API calls) in internal/github