Skip to content

Commit 635784d

Browse files
authored
Expand README for src/workflows (#58882)
1 parent 64d2089 commit 635784d

File tree

1 file changed

+97
-2
lines changed

1 file changed

+97
-2
lines changed

src/workflows/README.md

Lines changed: 97 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,100 @@
11
# Workflows
22

3-
This directory contains workflow scripts that cannot otherwise be in other subject folders.
3+
The workflows subject contains automation scripts that support GitHub Actions workflows, CLI tools, and repository automation. These scripts handle tasks like PR labeling, cache purging, content change analysis, and repository maintenance.
4+
5+
## Purpose & Scope
6+
7+
This subject is responsible for:
8+
- PR and issue automation (labeling, metadata, reviewer assignment)
9+
- Cache management (Fastly edge cache purging)
10+
- Content validation and reporting (content type checking, change tables)
11+
- Repository maintenance (orphan file cleanup, syncing)
12+
- Husky git hooks (pre-commit checks)
13+
- GitHub Actions support scripts
14+
15+
Note: This directory does not contain a `scripts/` folder since every file here would belong in `scripts/`. Files are organized flat at the top level with supporting utilities in `lib/`.
16+
17+
## Setup & Usage
18+
19+
### Running workflow scripts locally
20+
21+
Scripts are registered in `package.json`:
22+
23+
| Script | Command | Purpose |
24+
|--------|---------|---------|
25+
| content-changes-table-comment | `npm run content-changes-table-comment` | Analyzes content changes in PRs |
26+
| check-content-type | `npm run check-content-type` | Validates content types |
27+
| delete-orphan-translation-files | `npm run delete-orphan-translation-files` | Removes orphaned translations |
28+
| enable-automerge | `npm run enable-automerge` | Enables PR automerge |
29+
| purge-fastly-edge-cache | `npm run purge-fastly-edge-cache` | Purges Fastly CDN cache |
30+
| prevent-pushes-to-main | (Husky hook) | Prevents pushing to main |
31+
32+
### Running tests
33+
34+
```bash
35+
npm run test -- src/workflows/tests
36+
```
37+
38+
### GitHub Actions integration
39+
40+
Many scripts are called from GitHub Actions workflows in `.github/workflows/`. They typically:
41+
1. Run automatically on PR events, pushes, or schedules
42+
2. Use GitHub Actions context (`@actions/github`, `@actions/core`)
43+
3. Require `GITHUB_TOKEN` environment variable
44+
4. Post results as PR comments or update PR/issue metadata
45+
46+
## Data & External Dependencies
47+
48+
### Data inputs
49+
- GitHub API: PR data, issue data, file changes, commit history
50+
- Git repository: File contents, frontmatter, diff information
51+
- Environment variables: `GITHUB_TOKEN`, `FASTLY_TOKEN`, `BASE_SHA`, `HEAD_SHA`
52+
53+
### Dependencies
54+
- `@actions/github`, `@actions/core` - GitHub Actions SDK
55+
- `@octokit/rest` - GitHub API client
56+
- Fastly API - For cache purging
57+
- Various internal subjects for content parsing and validation
58+
59+
### Data outputs
60+
- PR/issue comments - Content change summaries, validation results
61+
- PR/issue labels - Applied via GitHub API
62+
- Cache purges - Fastly CDN invalidations
63+
- Exit codes - Success/failure for CI/CD
64+
65+
## Cross-links & Ownership
66+
67+
### Related subjects
68+
- [`src/frame`](../frame/README.md) - Frontmatter reading and path utilities
69+
- [`src/versions`](../versions/README.md) - Version detection for content changes
70+
- [`src/content-linter`](../content-linter/README.md) - Content validation
71+
- [`src/git`](../git/README.md) - Git utilities (if exists)
72+
- GitHub Actions workflows in `.github/workflows/` - Primary consumers
73+
74+
### Ownership
75+
- Team: Docs Engineering
76+
77+
## Current State & Next Steps
78+
79+
### Known limitations
80+
- Some scripts require specific environment variables and can't easily run locally without setup
81+
- Error handling varies across scripts
82+
- Documentation for individual scripts is sometimes inline-only
83+
84+
### Testing guidance
85+
- Most workflow scripts have limited automated test coverage
86+
- Test locally before deploying to Actions when possible
87+
- Use CLI variants (e.g., `content-changes-table-comment-cli.ts`) for local testing
88+
89+
### Adding new workflow scripts
90+
When adding a new script:
91+
1. Create the `.ts` file in `src/workflows/`
92+
2. Add to `package.json` scripts if it should be runnable via npm
93+
3. Document any required environment variables
94+
4. Add to `.github/workflows/` if it should run automatically
95+
5. Consider creating a `-cli.ts` variant for local testing
96+
6. Update this README if the script introduces new patterns
97+
98+
### Planned work
99+
- Standardize error handling and logging across scripts
4100

5-
This directory does not contain a `scripts/` folder, as every file in here would belong in `scripts/`.

0 commit comments

Comments
 (0)