Regenerate examples and docs #1573
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: Regenerate examples and docs | |
on: | |
schedule: | |
- cron: "0 */12 * * *" | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- "tests/**" | |
- "examples/**" | |
- "**.json" | |
- "**.csv" | |
- "**.html" | |
workflow_dispatch: | |
jobs: | |
regen_examples_and_docs: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: git config | |
run: | | |
git config --global user.name statsabot | |
git config --global user.email '' | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- run: curl -LsSf https://astral.sh/uv/install.sh | sh | |
- run: uv pip install -e .[docs] --system | |
- run: uv pip freeze | |
- name: Regenerate examples and docs | |
id: regen | |
run: python scripts/regenerate.py --download-typeshed | |
- name: Check the generated files with pre-commit | |
id: lint | |
uses: pre-commit/[email protected] | |
- name: Commit and push the changes | |
id: commit | |
if: >- | |
${{ | |
github.repository == 'AlexWaygood/typeshed-stats' | |
&& always() | |
&& steps.regen.outcome == 'success' | |
&& steps.lint.outcome == 'success' | |
}} | |
run: | | |
git add . | |
git diff --staged --quiet || git commit -m "👷 Automated regeneration of examples and docs" | |
git push | |
- name: Deploy docs | |
if: >- | |
${{ | |
github.repository == 'AlexWaygood/typeshed-stats' | |
&& always() | |
&& steps.regen.outcome == 'success' | |
&& steps.lint.outcome == 'success' | |
&& steps.commit.outcome == 'success' | |
}} | |
run: mkdocs gh-deploy -m "🚀 Deploying {sha} with MkDocs {version}" --force | |
create-issue-on-failure: | |
name: Create an issue if the automated regeneration failed | |
runs-on: ubuntu-latest | |
needs: [regen_examples_and_docs] | |
if: >- | |
${{ | |
github.repository == 'AlexWaygood/typeshed-stats' | |
&& always() | |
&& github.event_name == 'schedule' | |
&& needs.regen_examples_and_docs.result == 'failure' | |
}} | |
permissions: | |
issues: write | |
steps: | |
- uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
await github.rest.issues.create({ | |
owner: "AlexWaygood", | |
repo: "typeshed-stats", | |
title: `Automated regeneration of examples failed on ${new Date().toDateString()}`, | |
body: "Runs are listed here: https://github.com/AlexWaygood/typeshed-stats/actions/workflows/regen-examples-and-docs.yml", | |
}) |