Skip to content

TE6 Checkit

TE6 Checkit #2051

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
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Setup requirements
run: |
bash scripts/setup.sh
bash scripts/download-cache.sh
- name: Build precalculus activities
run: |
eval "$('conda' 'shell.bash' 'hook' 2> /dev/null)"
conda activate sage
pretext build -g precalculus-web-instructor
- name: Build calculus activities
run: |
eval "$('conda' 'shell.bash' 'hook' 2> /dev/null)"
conda activate sage
pretext build -g calculus-web-instructor
- name: Build linear algebra activities
run: |
eval "$('conda' 'shell.bash' 'hook' 2> /dev/null)"
conda activate sage
pretext build -g linear-algebra-web-instructor
- name: Stage builds and updated cache
run: |
eval "$('conda' 'shell.bash' 'hook' 2> /dev/null)"
conda activate sage
pretext deploy --stage-only
bash scripts/stage-cache.sh
- name: build and stage banks
run: |
eval "$('conda' 'shell.bash' 'hook' 2> /dev/null)"
conda activate sage
echo "Precalculus bank"
python scripts/build_bank.py precalculus --full
echo "Calculus bank"
python scripts/build_bank.py calculus --full
echo "Linear Algebra bank"
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-ghpages:
runs-on: ubuntu-latest
needs: build
if: 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
preview:
runs-on: ubuntu-latest
if: github.ref != format('refs/heads/{0}', github.event.repository.default_branch)
outputs:
markdown: ${{ steps.changes.outputs.markdown }}
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup requirements
run: |
bash scripts/setup.sh
bash scripts/download-cache.sh
- name: build previews of all changed files and stage
id: changes
run: |
eval "$('conda' 'shell.bash' 'hook' 2> /dev/null)"
conda activate sage
python -m scripts.quickbuild_changes
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: preview
if: 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: 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: |
cf_url = "${{ steps.cloudflare_publish.outputs.url }}"
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `${{ needs.preview.outputs.markdown }}`
})