Generate README with GH Actions #12
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: | |
- "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: | | |
if [ ! -f "README.md" ]; then | |
touch README.md | |
fi | |
- 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 | |
- name: Setup git | |
run: | | |
git config --local user.name "github-actions[bot]" | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git remote set-url origin https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} | |
- name: Push | |
run: | | |
if git update-index --refresh && git diff-index --quiet HEAD --; then | |
branch_name="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" | |
git add docs/help/* | |
git commit -m "Automated update of help docs" | |
git push origin HEAD:$branch_name | |
fi |