Generate README with GH Actions #2
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Generate README | |
on: | |
pull_request: | |
paths: | |
- "docs/*.md" | |
- "src/sim_recon/cli/parsing.py" | |
- "src/sim_recon/settings/formatting.py" | |
jobs: | |
build: | |
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: Get argparse help outputs | |
run: | | |
cd src/sim_recon/cli | |
export OTF_HELP_OUTPUT=$(python -c "import parsing; parsing.parse_otf_args(("--help",))") | |
export RECON_HELP_OUTPUT=$(python -c "import parsing; parsing.parse_recon_args(("--help",))") | |
- name: Get sections | |
run: | | |
cd docs | |
for file in sections/*; do | |
if [ -f "$file" ]; then | |
var_name="$(echo "${file^^}" | tr "./" "_")" | |
# Export file contents to an environment variable named from the path, e.g.: | |
# 'section/test_file.md' would be 'SECTION_TEST_FILE_MD' | |
export "${!var_name}"="$(<"$file")" | |
envsubst < "${!var_name}" # Substitute environment variables into each section (not other sections) | |
fi | |
done | |
- name: Fill template | |
run: | | |
cp -f docs/template.md README.md | |
envsubst < README.md |