Skip to content

Commit 3bec330

Browse files
committed
Improve GitHub Actions docs example
- Remove pip caching section (uv handles caching automatically) - Use Python API instead of subprocess for processing files - Use PEP 723 inline script dependencies with uv shebang
1 parent 3bce928 commit 3bec330

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

docs/usage/github-actions.md

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,19 @@ The workflow triggers on:
3737

3838
### Processing Multiple Files
3939

40-
To process multiple Markdown files, create a helper script:
40+
To process multiple Markdown files, create a helper script using [PEP 723](https://peps.python.org/pep-0723/) inline script dependencies:
4141

4242
```python
43-
#!/usr/bin/env python3
43+
#!/usr/bin/env -S uv run --script
44+
# /// script
45+
# requires-python = ">=3.10"
46+
# dependencies = ["markdown-code-runner"]
47+
# ///
4448
"""Update all markdown files that use markdown-code-runner."""
4549
from pathlib import Path
46-
import subprocess
50+
51+
from markdown_code_runner import update_markdown_file
52+
4753

4854
def find_markdown_files(root: Path) -> list[Path]:
4955
"""Find all markdown files containing code markers."""
@@ -54,6 +60,7 @@ def find_markdown_files(root: Path) -> list[Path]:
5460
files.append(md_file)
5561
return sorted(files)
5662

63+
5764
def main():
5865
root = Path(".")
5966
files = find_markdown_files(root / "docs")
@@ -65,25 +72,14 @@ def main():
6572

6673
for f in files:
6774
print(f"Processing {f}...")
68-
subprocess.run(["markdown-code-runner", str(f)], check=True)
75+
update_markdown_file(f)
76+
6977

7078
if __name__ == "__main__":
7179
main()
7280
```
7381

74-
### Caching Dependencies
75-
76-
Add caching to speed up your workflow:
77-
78-
```yaml
79-
- name: Cache pip packages
80-
uses: actions/cache@v4
81-
with:
82-
path: ~/.cache/pip
83-
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
84-
restore-keys: |
85-
${{ runner.os }}-pip-
86-
```
82+
Run it with `uv run update_docs.py` or make it executable and run directly.
8783

8884
### Only Run on Specific Files
8985

0 commit comments

Comments
 (0)