Skip to content

xfer help info from GSAS-II docs repo #29

xfer help info from GSAS-II docs repo

xfer help info from GSAS-II docs repo #29

Workflow file for this run

name: xfer help info from GSAS-II docs repo
# This updates the help file to match the contents of the MDhelp directory
# in the GSAS-II-tutorials repo. It is triggered from the builddocsite.yml
# workflow in the GSAS-II-tutorials repo, or runs daily, or can be triggered manually.
on:
repository_dispatch: # run from Web API
workflow_dispatch: # manual trigger for testing
schedule:
- cron: '0 0 * * *' # Run daily at midnight UTC
permissions:
contents: write
id-token: write
pages: write
jobs:
check_files: # Check if files need updating
runs-on: ubuntu-latest
outputs:
files_changed: ${{ steps.compare.outputs.files_changed }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout tutorials repo
uses: actions/checkout@v4
with:
repository: AdvancedPhotonSource/GSAS-II-tutorials.git
path: _docs
ref: main
sparse-checkout: MDhelp/docs
sparse-checkout-cone-mode: true
- name: Compare files
id: compare
run: |
# Check if any .md files in _docs/MDhelp/docs are newer than GSASII/help
# Only compare markdown source files, not directory metadata
files_changed="false"
if [ ! -d "GSASII/help" ]; then
echo "help directory does not exist, will build"
files_changed="true"
elif [ ! -d "_docs/MDhelp/docs" ]; then
echo "docs directory does not exist"
files_changed="false"
else
# Get the most recent commit date for .md files in docs directory
docs_latest=$(cd _docs && find MDhelp/docs -name "*.md" -type f | xargs git log -1 --format=%cI -- 2>/dev/null | sort -r | head -1)
# Get the most recent commit date for the help directory
help_latest=$(git log -1 --format=%cI -- "GSASII/help/" 2>/dev/null || echo "")
if [ -z "$docs_latest" ]; then
echo "Could not get commit date for markdown files in docs directory"
files_changed="false"
elif [ -z "$help_latest" ]; then
echo "help directory has no commit history, will build"
files_changed="true"
else
# Compare ISO 8601 dates (they sort correctly as strings)
if [ "$docs_latest" > "$help_latest" ]; then
echo "Markdown docs are newer (docs: $docs_latest, help: $help_latest)"
files_changed="true"
else
echo "help directory is current (docs: $docs_latest, help: $help_latest)"
files_changed="false"
fi
fi
fi
echo "files_changed=$files_changed" >> $GITHUB_OUTPUT
echo "Files changed: $files_changed"
build: # Build web pages (only if files changed)
needs: check_files
if: needs.check_files.outputs.files_changed == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout
# get the help pages from GSAS-II docs repo
uses: actions/checkout@v4
with:
repository: AdvancedPhotonSource/GSAS-II-tutorials.git
path: _docs
ref: main
- name: Python setup
uses: actions/setup-python@v3
- name: mkdocs setup
run: |
pip install mkdocs mkdocs-material python-markdown-math mkdocs-static-i18n
pip install mkdocs-to-pdf pymdown-extensions
# MD help conversion
- name: convert MDhelp
run: |
pwd
cd _docs/MDhelp
mkdocs build
python findMDanchors.py # create an anchor index
rm -rf ../../GSASII/help/assets/javascripts/
rm -rf ../../GSASII/help/assets/stylesheets/
cp -vr site/* ../../GSASII/help
cd ../../GSASII/help
pwd
ls -lt
- name: git diagnostics
run: |
pwd
git status
git diff
git add GSASII/help
echo "After add"
git status
- name: commit changes
run: |
git add GSASII/help
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git commit -m"update help files"
- name: push help into repo
run: |
git push