Started a PreTeXt book.

This commit is contained in:
andyeisenberg
2025-12-28 16:44:30 +00:00
parent a6bd475da4
commit 5602f92eb7
12 changed files with 664 additions and 18 deletions
+117
View File
@@ -0,0 +1,117 @@
# This file was automatically generated with PreTeXt 2.32.0.
# If you modify this file, PreTeXt will no longer automatically update it.
#
# This workflow file can be used to automatically build a project and create
# an artifact for deployment. It can also be used to deploy the project to
# GitHub Pages or Cloudflare Pages.
#
# The workflow is triggered on pull requests or can be run manually. You can uncomment
# the `push` event to have it run on pushes to the main branch as well.
name: PreTeXt-CLI Actions
on:
# Runs on pull requests
pull_request:
branches: ["*"]
## Runs on pushes to main
#push:
# branches: ["main"]
# Runs on demand
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
container: oscarlevin/pretext-full
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: install deps
run: pip install -r requirements.txt
- name: set up node
uses: actions/setup-node@v4
with:
node-version: '22'
- name: install local ptx files
run: pretext --version
- name: build deploy targets
run: |
version="$(pretext --version)"
major="$(echo $version | cut -d '.' -f 1)"
minor="$(echo $version | cut -d '.' -f 2)"
if [ "$major" -ge 2 -a "$minor" -ge 5 ]; then
echo "PreTeXt version is 2.5 or greater; using new build command"
pretext build --deploys
else
echo "PreTeXt version is less than 2.5, using old build command"
pretext build
fi
- name: stage deployment
run: pretext deploy --stage-only
- name: Bundle output/stage as artifact
uses: actions/upload-artifact@v4
with:
name: deploy
path: output/stage
deploy-cloudflare:
runs-on: ubuntu-latest
needs: build
if: vars.CLOUDFLARE_PROJECT_NAME != ''
permissions:
contents: read
deployments: write
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: deploy
path: deploy
- name: Create 404.html
run: echo "404 page not found" >> deploy/404.html
- name: Publish to Cloudflare
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: ${{ vars.CLOUDFLARE_PROJECT_NAME }}
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.head_ref || github.ref_name }}
directory: deploy
deploy-ghpages:
runs-on: ubuntu-latest
needs: build
if: vars.PTX_ENABLE_DEPLOY_GHPAGES == 'yes' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "page"
cancel-in-progress: false
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Download website artifact
uses: actions/download-artifact@v4
with:
name: deploy
path: deploy
- name: Setup GitHub Pages
id: check
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: deploy
- name: Deploy to Github Pages
id: deployment
uses: actions/deploy-pages@v4
+68
View File
@@ -0,0 +1,68 @@
# This file was automatically generated with PreTeXt 2.32.0.
# If you modify this file, PreTeXt will no longer automatically update it.
#
name: Build and Deploy
on:
# Currently, this workflow only runs when manually selected (the `workflow_dispatch` event).
# If you would like it to run on other events, uncomment some of the lines below.
# # Runs on pull requests
# pull_request:
# branches: ["*"]
# # Runs on pushes to main
# push:
# branches: ["main"]
# # Runs every day at 00:00 UTC
# schedule:
# - cron: '0 0 * * *'
# Runs on demand
workflow_dispatch:
permissions:
contents: write
jobs:
build-and-deploy:
runs-on: ubuntu-latest
container: oscarlevin/pretext-full
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: set up node
uses: actions/setup-node@v4
with:
node-version: '22'
- name: add gh-cli
run: |
apt-get update
apt-get install gh jq -y
- name: setup git config
run: |
git config --global --add safe.directory $(pwd)
git config user.name "${{ github.actor }} via GitHub Actions"
git config user.email "${{ github.actor }}@github_actions.no_reply"
- name: install deps
run: pip install -r requirements.txt --break-system-packages
- name: install local ptx files
run: pretext --version
- name: build deploy targets
run: pretext build --deploys
- name: run deploy
run: pretext deploy --no-push
- name: push gh-pages branch
run: git push origin gh-pages --force
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}