How golles/mock-yaml-secrets-action works
Project type and purpose
• This is an open-source GitHub Action written in TypeScript/Node.js.
• Its purpose is to scan a user’s YAML files in a repository for secret-looking keys (via regex rules) and emit a secrets.yaml file with dummy values, so later CI/CD steps don’t fail due to missing secrets.
File structure
• Top-level entrypoint for the Action: action.yml
• Source code in src/:
• index.ts (reads inputs, kicks off processing)
• main.ts (core orchestration)
• utils/: config.ts (parses JSON config), files.ts (recursive file scanning), rules.ts (regex matching)
• Build artifacts in dist/ (bundled with Rollup as CommonJS for Node)
• Tests in __tests__/ with fixtures in __fixtures__/
• Configuration & metadata: package.json, rollup.config.ts, TypeScript configs, GitHub workflows for CI, linting, release.
README for additional insights
• Inputs: configFile path pointing to a JSON specifying:
• directory to scan
• excludePaths, secretFile name, defaultValue, rules map
• Usage under a GitHub workflow: checks out code, runs “Mock secrets” step, then downstream build.
a. Main components
1. GitHub Actions Runner (host environment)
2. Checkout & Setup step (retrieves user repo + this Action)
3. Mock-YAML-Secrets Action container/process:
• Action Entrypoint (action.yml)
• Runtime (Node.js)
• Bundled code (dist/main.js)
• Modules: Config Loader, File Scanner, Rule Engine, YAML Generator
4. Input artifacts: user’s YAML files + JSON config file
5. Output artifact: generated secrets.yaml in workspace
6. Downstream steps (other Actions or build steps) that consume secrets.yaml
b. Relationships & data flow
• Runner invokes Action → reads inputs → invokes Config Loader
• File Scanner walks target directory, filters by excludePaths
• For each YAML file, data passes to Rule Engine → produces key/value pairs
• YAML Generator emits secrets.yaml
• Output file lands back on the runner workspace for next job
c. Architectural patterns & principles
• Modular design: each concern in its own utility module (single responsibility)
• Pipeline pattern: Input → Transform → Output
• CLI/Action abstraction: action.yml ties GitHub Actions meta to code
d. Relevant technologies/frameworks
• TypeScript & Node.js runtime
• Rollup bundler (produces dist/)
• Jest for testing (fixtures under __fixtures__)
• GitHub Actions metadata (action.yml)
• GitHub workflows for CI/CD in .github/workflows/