Skip to content

Submitting this to see if I am doing it correctly #651

Submitting this to see if I am doing it correctly

Submitting this to see if I am doing it correctly #651

Workflow file for this run

name: PreTeXt-CLI Actions (TBIL Customization)
on:
# Runs on pull requests
pull_request:
branches: ["*"]
# Runs on pushes to main
push:
branches: ["main"]
# Runs on demand
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
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: quick build instructor versions
id: quickbuild
if: github.ref != format('refs/heads/{0}', github.event.repository.default_branch) && github.event_name != 'workflow_dispatch'
run: |
pretext build precal-web-instructor -q
pretext build cal-web-instructor -q
pretext build la-web-instructor -q
- name: build all deploy targets
if: steps.quickbuild.outcome == 'skipped'
run: pretext build --deploys
- name: stage deployment
run: pretext deploy --stage-only
- name: build and stage all banks
if: steps.quickbuild.outcome == 'skipped'
run: |
python scripts/build_bank.py precalculus --full
python scripts/build_bank.py calculus --full
python scripts/build_bank.py linear-algebra --full
- 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 != '' && github.ref != format('refs/heads/{0}', github.event.repository.default_branch)
permissions:
contents: read
deployments: write
pull-requests: 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: Delete CheckIt builds not supported by CloudFlare
run: find . -name "bank.json" -type f -delete
- name: Publish to Cloudflare
id: cloudflare_publish
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
- name: Report preview link
uses: actions/github-script@v6
if: github.event_name == 'pull_request'
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '## 🚀 Preview available 🚀\n\n${{ steps.cloudflare_publish.outputs.url }}\n\n- [Precalculus](${{ steps.cloudflare_publish.outputs.url }}/preview/precalculus/instructor/frontmatter)\n\n- [Calculus](${{ steps.cloudflare_publish.outputs.url }}/preview/calculus/instructor/frontmatter)\n\n- [Linear Algebra](${{ steps.cloudflare_publish.outputs.url }}/preview/linear-algebra/instructor/frontmatter)'
})
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
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