How thebrutalx/factorio-mod-uploader-action works
Project type and purpose
• This is a GitHub Action implemented in Node.js/TypeScript whose sole purpose is to automate packaging and uploading of Factorio mods to the Factorio Mod Portal.
• The README confirms three action phases: “validate” (check mod metadata), “compress” (zip the mod), and “upload” (send the zip via Factorio API).
File structure
• Top-level files:
• action.yml – action metadata (inputs, outputs, entrypoint)
• dist/bundle.js – compiled & bundled action code
• src/index.ts – main entrypoint that delegates to phases
• src/phases/ – contains the three core processes: validate.ts, compress.ts, upload.ts plus baseProcess.ts
• src/services/ – parsing logic (FactorioIgnoreParser, FactorioModInfoParser) and FactorioModPortalApiService (HTTP client and interfaces)
• src/utils/ – helper modules (ActionHelper for I/O, zipper for archive creation)
• src/interfaces, src/types, src/constants, src/errors – type definitions and error classes supporting the core logic
• Build & test config: tsconfig.json, webpack.config.js, jest.config.js, tests in src/__tests__.
README for additional insights
• Describes usage in a GitHub workflow: three sequential steps—validate, compress, upload—each implemented by the same action package but with different with: action: inputs.
• Points out integration with actions/checkout and secret inputs for the API key.
a. Main components
1. GitHub Actions Runner (host environment)
2. Action Definition (action.yml)
3. Node.js Runtime & Entrypoint (dist/bundle.js ↔ src/index.ts)
4. Phase Orchestrator (baseProcess.ts)
5. Phase Implementations:
• Validate Phase (src/phases/validate.ts)
• Compress Phase (src/phases/compress.ts + zipper util)
• Upload Phase (src/phases/upload.ts + FactorioModPortalApiService)
6. Parsers & Utilities (FactorioIgnoreParser, FactorioModInfoParser, ActionHelper)
7. External Service: Factorio Mod Portal API
8. Developer Tools (tests, build scripts) – optional to show or keep separate
b. Relationships & interactions
• The GitHub Runner loads action.yml → spawns Node.js process → executes bundled entrypoint.
• Entrypoint reads input parameters (action type, API key, etc.) via ActionHelper.
• Entrypoint instantiates BaseProcess, which in turn invokes the selected Phase module.
• Validate Phase uses FactorioModInfoParser and FactorioIgnoreParser to check project structure and manifest.
• Compress Phase zips the mod folder using zipper utility.
• Upload Phase calls FactorioModPortalApiService (HTTP client) to send the zip file, using the API key.
• Errors bubble up into custom error classes; successful steps emit outputs back to GitHub via ActionHelper.
c. Architectural patterns & design principles
• Strategy pattern: phases share a common BaseProcess interface (IBaseProcess).
• Single-responsibility modules: parsers, services, utils are decoupled.
• Dependency injection via inputs/options rather than hard-coded values.
• All external side-effects (file I/O, HTTP calls) abstracted behind utility/service layers.
d. Key technologies/frameworks
• Node.js & TypeScript
• Webpack for bundling into dist/bundle.js
• Jest for testing
• GitHub Actions metadata (action.yml) and Runner environment variables