Repository Type: GitHub Action
Primary Language: JavaScript (CommonJS, Node.js 22+)
Build Tool: @vercel/ncc
Testing: Jest
Linting: ESLint 9 (flat config)
Formatting: Prettier
CI/CD: GitHub Actions
Quality: SonarCloud, CodeQL, Codecov
Pre-commit: Lefthook
GitHub Action that delegates code changes to GitHub Copilot CLI, creates feature branches, commits changes, opens PRs, and assigns them to the workflow actor. No auto-merge. Human review required.
Key Workflow:
- Validate optional file input
- Execute Copilot CLI with instructions
- Create timestamped branch
- Commit changes with conventional commit messages
- Run Copilot review pass
- Create PR with description
- Assign PR to workflow actor
src/index.js: Main action logicdist/index.js: Compiled bundle (committed to repo, required by GitHub Actions)
validateFilename(): Sanitize and validate filename input (path traversal protection)validateFile(): Check file existence, size limits (1MB max), and typerunCopilot(): Execute @github/copilot npm package with token and instructionscreateBranch(): Create timestamped feature branchcommitAndPush(): Configure git, commit changes, push to remotecreatePullRequest(): Use Octokit to create PR via GitHub APIassignPR(): Assign PR to workflow actor
- Input sanitization via
sanitize-filenameandvalidator - Path traversal prevention (rejects absolute paths and
..) - File size limits (1MB) to prevent memory exhaustion
- No shell execution of user input
- Structured logging via
pino
| Name | Required | Default | Validation |
|---|---|---|---|
PRIVATE_TOKEN |
Yes | - | Must be valid GitHub PAT |
filename |
No | '' |
Sanitized, no path traversal, max 255 chars |
branch |
No | main |
Base branch for PR |
| Name | Description |
|---|---|
pr_number |
Created PR number |
branch |
Feature branch name |
Job: setup
Purpose: Extract Node.js version from Volta configuration in package.json
Outputs: node-version (default: 22 if not found)
Job: format
Command: npm run format:check
Purpose: Validate Prettier formatting compliance
Blocking: Yes
Job: lint
Command: npm run lint
Purpose: ESLint validation, Responsible AI commit footer enforcement
Blocking: Yes
Job: build
Command: npm run build
Purpose: Compile action with @vercel/ncc into dist/
Artifacts: Uploads dist/ for 7 days
Blocking: Yes
Job: test
Command: npm test
Purpose: Execute Jest test suite
Coverage Target: 70% (branches, functions, lines, statements)
Blocking: Yes
Job: codecov
Command: npm run test:coverage
Purpose: Upload coverage to Codecov
Runs: Only on push to main (not PRs)
Blocking: No (fail_ci_if_error: false)
Job: gate
Purpose: Final validation that all quality agents passed
Dependencies: format, lint, build, test
Blocking: Yes
Workflow: .github/workflows/codeql.yml
Language: JavaScript
Query Suite: security-and-quality
Schedule: Weekly (Mondays 00:00 UTC)
Runs: Push to main, PRs
Blocking: No (reports to Security tab)
Workflow: .github/workflows/secret-scanning.yml
Tool: Gitleaks v2
Scope: Full git history
Runs: Push to main, PRs
Blocking: Yes (prevents secret leaks)
Workflow: .github/workflows/sonarcloud.yml
Version: v3.1.0 (pinned)
Runs: Push to main, PRs
Metrics: Code smells, bugs, vulnerabilities, tech debt
Dashboard: https://sonarcloud.io/project/overview?id=ChecKMarKDevTools_delegate-action
Workflow: .github/workflows/release-please.yml
Version: v4
Trigger: Push to main
Purpose: Parse conventional commits, generate changelog, create release PRs, bump versions
Location: __tests__/index.test.js
Framework: Jest
Mocking: @actions/core, @actions/exec, @actions/github, fs, pino
Coverage Target: 70% minimum
- Filename validation (empty, too long, absolute paths, traversal attempts, valid)
- File validation (existence, size limits, file vs directory)
- Copilot execution (version check, token passing, error handling)
- Branch creation (new branch, existing branch fallback)
- Commit/push (git config, change detection, no-change skip, error handling)
- PR creation (API success, API errors)
- PR assignment (API success, API errors)
- Input validation (required token, default branch)
{
global: {
branches: 70,
functions: 70,
lines: 70,
statements: 70
}
}Input Validation:
- All filenames sanitized with
sanitize-filename - Validator.js for additional validation
- Reject absolute paths
- Reject path traversal (
..) - Max filename length: 255 characters
- Max file size: 1MB
Secret Management:
- Never log secrets
- Use GitHub secrets for tokens
- Gitleaks scans every commit
- CodeQL weekly SAST
Permissions:
- CI:
contents: read,pull-requests: write,checks: write - CodeQL:
actions: read,contents: read,security-events: write - Secret Scanning:
contents: read,security-events: write - Release Please:
contents: write,pull-requests: write
ESLint:
- ECMAScript 2024
- CommonJS modules
- Prettier integration
- No unused vars (except prefixed with
_) - Console allowed (structured logging via pino)
Prettier:
- Auto-format via lefthook pre-commit hook
- Targets:
*.{js,json,md,yml,yaml}
Commitlint:
- Conventional Commits enforced
- Responsible AI attribution required via
@checkmarkdevtools/commitlint-plugin-rai - Allowed types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert
Setup:
npm install # Installs deps + lefthook hooksBuild:
npm run build # Compiles to dist/Lint:
npm run lint # ESLint checkFormat:
npm run format # Auto-fix
npm run format:check # Check onlyTest:
npm test # Run tests
npm run test:coverage # With coveragePre-commit Hooks (Lefthook):
- Format (auto-fixes)
- Lint (must pass)
- Test (must pass)
setup
โโโ format โโโโโ
โโโ lint โโโโโโโค
โโโ build โโโโโโผโโ> gate
โโโ test โโโโโโโ
โโโ codecov (main only)
Parallel Execution: format, lint, build, test all run in parallel after setup
Quality Gate: Blocks merge if any quality agent fails
Coverage Upload: Only after test succeeds on main branch
Required for Merge:
- โ Format check passes
- โ Lint check passes
- โ Build succeeds
- โ Tests pass (70% coverage minimum)
- โ No secrets detected
- โ Quality gate passes
Advisory (non-blocking):
- CodeQL security alerts
- SonarCloud quality metrics
- Codecov coverage trends
Graceful Degradation:
- Copilot execution errors โ log warning, continue
- Commit errors (no changes) โ log info, skip
- PR assignment errors โ log warning, continue
Hard Failures:
- Missing PRIVATE_TOKEN โ setFailed
- Invalid filename โ setFailed
- File too large โ setFailed
- PR creation fails โ return null, log error
Logging:
- Use
pinofor structured JSON logs - Include context (filename, branch, error messages)
- No secrets in logs
Compiled Output:
dist/index.js: Single bundled file created by @vercel/ncc- Must be committed to repo (GitHub Actions requirement)
- Generated via
npm run build
Excluded from Bundle:
- node_modules (bundled into dist)
- Tests
- Dev dependencies
Production:
@actions/core@^2.0.2: GitHub Actions core utilities@actions/exec@^2.0.0: Execute shell commands@actions/github@^7.0.0: Octokit GitHub API clientpino@^10.2.0: Structured loggingpino-pretty@^13.1.3: Log formattingsanitize-filename@^1.6.3: Filename sanitizationvalidator@^13.15.26: Input validation
Development:
jest@^29.7.0: Testing frameworkeslint@^9.39.2: Lintingprettier@^3.3.3: Code formatting@vercel/ncc@^0.38.3: Bundler@commitlint/*@^20.3.1: Commit message validationlefthook@^2.0.15: Git hooks
When working in this repository:
- Never modify CI configuration without explicit request
- Always export functions in
src/index.jsfor testability - Always update tests when changing functionality
- Always run validation loop before completion:
npm run formatnpm run lintnpm run buildnpm test
- Always maintain 70%+ test coverage
- Never commit secrets or sensitive data
- Always use conventional commits with RAI attribution
- Always update dist/ after src/ changes
- Never introduce breaking changes without major version bump
- Always validate inputs for security (path traversal, size limits)
Add new feature:
- Update
src/index.js - Export new functions in module.exports
- Add tests in
__tests__/index.test.js - Run
npm run buildto update dist/ - Verify coverage:
npm run test:coverage - Commit with conventional commit + RAI footer
Fix bug:
- Write failing test
- Fix implementation
- Verify test passes
- Run full validation loop
- Update dist/
Update dependencies:
- Run
npm outdated - Update package.json versions
- Run
npm install - Test thoroughly
- Update dist/
- Commit with
build:prefix
- GitHub Actions Toolkit
- Conventional Commits
- Jest Documentation
- ESLint Flat Config
- Lefthook Documentation
Last Updated: 2026-01-17
Node Version: 22.13.1 (Volta)
Action Version: 1.0.0