Skip to content

Update DoD Prohibited Substances page #180

Update DoD Prohibited Substances page

Update DoD Prohibited Substances page #180

Workflow file for this run

name: Update DoD Prohibited Substances page
permissions:
contents: write
pull-requests: write
concurrency:
group: update-prohibited-substances
cancel-in-progress: true
on:
push:
branches:
- main
schedule:
- cron: '0 0 * * *' # Runs daily at midnight UTC
workflow_dispatch:
jobs:
check-for-changes:
runs-on: ubuntu-latest
outputs:
has-changes: ${{ steps.check-changes.outputs.has-changes }}
changes-summary: ${{ steps.check-changes.outputs.changes-summary }}
steps:
- name: Cache uv dependencies
uses: actions/cache@v4
with:
path: ~/.cache/uv
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2 # Need history to compare with previous version
- name: Cache UNII data
uses: actions/cache@v4
with:
path: .cache/unii_data
key: unii-data-${{ runner.os }}-${{ github.run_id }}
restore-keys: |
unii-data-${{ runner.os }}-
- name: Cache PubChem data
uses: actions/cache@v4
with:
path: .cache/pubchem
key: pubchem-${{ runner.os }}-${{ github.run_id }}
restore-keys: |
pubchem-${{ runner.os }}-
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.14'
- name: Install uv
run: pip install uv
- name: Install dependencies
run: uv sync
- name: Check for substance changes
id: check-changes
run: |
uv run python workflow_helper.py check-changes
update-and-deploy:
needs: check-for-changes
runs-on: ubuntu-latest
steps:
- name: Cache uv dependencies
uses: actions/cache@v4
with:
path: ~/.cache/uv
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Cache UNII data
uses: actions/cache@v4
with:
path: .cache/unii_data
key: unii-data-${{ runner.os }}-${{ github.run_id }}
restore-keys: |
unii-data-${{ runner.os }}-
- name: Cache PubChem data
uses: actions/cache@v4
with:
path: .cache/pubchem
key: pubchem-${{ runner.os }}-${{ github.run_id }}
restore-keys: |
pubchem-${{ runner.os }}-
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.14'
- name: Install uv
run: pip install uv
- name: Install dependencies
run: uv sync
- name: Regenerate data and documentation
env:
DOD_USE_PUBCHEM_DATA: "true"
run: |
uv run python generate_docs.py
- name: Build site
run: uv run zensical build
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./site
publish_branch: gh-pages
- name: Log deployment results
run: |
if [ "${{ needs.check-for-changes.outputs.has-changes }}" = "true" ]; then
echo "✅ Changes detected: ${{ needs.check-for-changes.outputs.changes-summary }}"
echo "📖 GitHub Pages site updated with latest data"
echo "🔄 Changes automatically deployed"
# Show summary from temp JSON if available
TEMP_SUMMARY="/tmp/changes_summary.json"
if [ -f "$TEMP_SUMMARY" ]; then
echo "📊 Detailed change summary:"
cat "$TEMP_SUMMARY" | python -m json.tool
elif [ -f "changes_summary_temp.json" ]; then
echo "📊 Detailed change summary:"
cat changes_summary_temp.json | python -m json.tool
fi
else
echo "✅ No changes detected: Documentation regenerated and deployed"
echo "📖 GitHub Pages site refreshed with existing data"
fi