Generate README with GH Actions #21
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 help docs and README | |
on: | |
pull_request: | |
paths: | |
- "src/sim_recon/cli/parsing/*" | |
- "src/sim_recon/settings/formatting.py" | |
env: | |
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
jobs: | |
generate-help-docs: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- name: Display Python version | |
run: python -c "import sys; print(sys.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: Get 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 help docs changes (if any) | |
run: | | |
git add docs/* | |
git update-index --refresh | |
if ! git diff-index --cached --quiet HEAD; then | |
echo "Committing changes to help docs to branch $BRANCH_NAME" | |
git commit -m "Automated update of help docs" | |
git push origin HEAD:$BRANCH_NAME | |
fi |