Skip to content

Commit

Permalink
Update workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Fish committed Sep 6, 2024
1 parent 6dfced0 commit 2673705
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 47 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/README from docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Generate README

on:
pull_request:
paths:
- "docs/**/*"
workflow_run:
workflows:
- "generate_help_docs"

jobs:
make-README:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
steps:
- uses: actions/checkout@v4
- name: "Fill template"
working-directory: "docs/"
timeout-minutes: 0.1
run: |
sub_doc_parts_from() {
template="$1"
directory="$2"
for file in "$directory"/*; do
if [ -f "$file" ]; then
placeholder="{{ $(echo "${file^^}" | tr ./ _) }}"
echo "Saving $file to $placeholder with expanded environment variables" >&2
# Export file contents to text following a pattern in template.md, e.g.:
# section/test_file.md would replace "{{ SECTION_TEST_FILE_MD }}""
template="${template//"$placeholder"/"$(<"$file")"}"
fi
done
echo "$template"
}
sub_doc_parts_from "$(sub_doc_parts_from "$(<template.md)" "sections")" "help">../README.md
33 changes: 33 additions & 0 deletions .github/workflows/generate_help_docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Generate README

on:
pull_request:
paths:
- "src/sim_recon/cli/parsing/*"
- "src/sim_recon/settings/formatting.py"

jobs:
generate-help-docs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Copy template
run: cp -f docs/template.md README.md
- name: Install (without dependencies)
run: |
python -m pip install --upgrade pip
python -m pip install . --no-deps
- name: Ensure README exists
run: touch README.md
- name: Getting help strings from package
run: |
python -m sim_recon.cli.parsing.otf '--help' >docs/help/sim_otf.txt
python -m sim_recon.cli.parsing.recon '--help' >docs/help/sim_recon.txt
python -m sim_recon.cli.parsing.otf_view '--help' >docs/help/otf_view.txt
47 changes: 0 additions & 47 deletions .github/workflows/generate_readme.yaml

This file was deleted.

0 comments on commit 2673705

Please sign in to comment.