Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/generate-readme.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Autogenerate README

on:
pull_request: {}

jobs:
generate-readme:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r .utils/requirements.txt

- name: Generate README
run: python .utils/generate_readme.py

- name: Check for uncommitted README changes
run: |
git add README.md
git diff --cached --exit-code || {
echo "::error::README.md is out of date or modified manually. Please re-run the generate_readme script and commit the result.";
exit 1;
}
2 changes: 1 addition & 1 deletion .utils/generate_readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def extract_metadata(readme_path):
metadata = yaml.safe_load(match.group(1))
except yaml.YAMLError as e:
print("Error parsing YAML metadata in", readme_path, ":", e)
return None
raise e

return metadata

Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ To contribute a tutorial, please follow these steps:
- `blog_post_url` - the url to blog post (optional)
- `video_url` - the url to the video (optional)
- `visualize_url` - the url to Foxglove visualization (optional)

When creating a merge request, a GitHub action should automatically regenerate the README based on your metadata. To test it yourself, you can run the python script `.utils/generate_readme.py` in the root of this repo.
4. Install generate_readme.py dependencies: `pip install -r .utils/requirements.txt`
5. Regenerate the main README.md by running `python .utils/generate_readme.py` from the root of the repo