Skip to content

Commit bca93c7

Browse files
committed
deploy m2 chapter
1 parent 0dff184 commit bca93c7

4 files changed

Lines changed: 179 additions & 1 deletion

File tree

.github/workflows/pretext-cli.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# This file was automatically generated with PreTeXt 2.17.0.
2+
# If you modify this file, PreTeXt will no longer automatically update it.
3+
#
4+
# This workflow file can be used to automatically build a project and create
5+
# an artifact for deployment. It can also be used to deploy the project to
6+
# GitHub Pages or Cloudflare Pages.
7+
#
8+
# The workflow is triggered on pull requests or can be run manually. You can uncomment
9+
# the `push` event to have it run on pushes to the main branch as well.
10+
name: PreTeXt-CLI Actions
11+
on:
12+
# Runs on pull requests
13+
pull_request:
14+
branches: ["*"]
15+
## Runs on pushes to main
16+
#push:
17+
# branches: ["main"]
18+
# Runs on demand
19+
workflow_dispatch:
20+
21+
jobs:
22+
build:
23+
runs-on: ubuntu-latest
24+
container: oscarlevin/pretext:full
25+
26+
steps:
27+
- name: Checkout source
28+
uses: actions/checkout@v4
29+
30+
- name: install deps
31+
run: pip install -r requirements.txt
32+
33+
- name: install local ptx files
34+
run: pretext --version
35+
36+
- name: build deploy targets
37+
run: |
38+
version="$(pretext --version)"
39+
major="$(echo $version | cut -d '.' -f 1)"
40+
minor="$(echo $version | cut -d '.' -f 2)"
41+
if [ "$major" -ge 2 -a "$minor" -ge 5 ]; then
42+
echo "PreTeXt version is 2.5 or greater; using new build command"
43+
pretext build --deploys
44+
else
45+
echo "PreTeXt version is less than 2.5, using old build command"
46+
pretext build
47+
fi
48+
- name: stage deployment
49+
run: pretext deploy --stage-only
50+
51+
- name: Bundle output/stage as artifact
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: deploy
55+
path: output/stage
56+
57+
deploy-cloudflare:
58+
runs-on: ubuntu-latest
59+
needs: build
60+
if: vars.CLOUDFLARE_PROJECT_NAME != ''
61+
permissions:
62+
contents: read
63+
deployments: write
64+
65+
steps:
66+
- name: Download artifact
67+
uses: actions/download-artifact@v4
68+
with:
69+
name: deploy
70+
path: deploy
71+
- name: Create 404.html
72+
run: echo "404 page not found" >> deploy/404.html
73+
- name: Publish to Cloudflare
74+
uses: cloudflare/pages-action@v1
75+
with:
76+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
77+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
78+
projectName: ${{ vars.CLOUDFLARE_PROJECT_NAME }}
79+
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
80+
branch: ${{ github.head_ref || github.ref_name }}
81+
directory: deploy
82+
83+
deploy-ghpages:
84+
runs-on: ubuntu-latest
85+
needs: build
86+
if: vars.PTX_ENABLE_DEPLOY_GHPAGES == 'yes' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
87+
permissions:
88+
contents: read
89+
pages: write
90+
id-token: write
91+
concurrency:
92+
group: "page"
93+
cancel-in-progress: false
94+
environment:
95+
name: github-pages
96+
url: ${{ steps.deployment.outputs.page_url }}
97+
steps:
98+
- name: Download website artifact
99+
uses: actions/download-artifact@v4
100+
with:
101+
name: deploy
102+
path: deploy
103+
- name: Setup GitHub Pages
104+
id: check
105+
uses: actions/configure-pages@v4
106+
- name: Upload artifact
107+
uses: actions/upload-pages-artifact@v3
108+
with:
109+
path: deploy
110+
- name: Deploy to Github Pages
111+
id: deployment
112+
uses: actions/deploy-pages@v4
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# This file was automatically generated with PreTeXt 2.17.0.
2+
# If you modify this file, PreTeXt will no longer automatically update it.
3+
#
4+
5+
name: Build and Deploy
6+
on:
7+
# Currently, this workflow only runs when manually selected (the `workflow_dispatch` event).
8+
# If you would like it to run on other events, uncomment some of the lines below.
9+
10+
# # Runs on pull requests
11+
# pull_request:
12+
# branches: ["*"]
13+
14+
# # Runs on pushes to main
15+
# push:
16+
# branches: ["main"]
17+
18+
# # Runs every day at 00:00 UTC
19+
# schedule:
20+
# - cron: '0 0 * * *'
21+
22+
# Runs on demand
23+
workflow_dispatch:
24+
25+
permissions:
26+
contents: write
27+
28+
jobs:
29+
build-and-deploy:
30+
runs-on: ubuntu-latest
31+
container: oscarlevin/pretext:small
32+
33+
steps:
34+
- name: Checkout source
35+
uses: actions/checkout@v4
36+
37+
- name: add gh-cli
38+
run: |
39+
apt-get update
40+
apt-get install gh jq -y
41+
42+
- name: setup git config
43+
run: |
44+
git config --global --add safe.directory $(pwd)
45+
git config user.name "${{ github.actor }} via GitHub Actions"
46+
git config user.email "${{ github.actor }}@github_actions.no_reply"
47+
48+
- name: install deps
49+
run: pip install -r requirements.txt --break-system-packages
50+
51+
- name: install local ptx files
52+
run: pretext --version
53+
54+
- name: build deploy targets
55+
run: pretext build --deploys
56+
57+
- name: run deploy
58+
run: pretext deploy --no-push
59+
60+
- name: push gh-pages branch
61+
run: git push origin gh-pages --force
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This file was automatically generated with PreTeXt 2.16.1.
1+
# This file was automatically generated with PreTeXt 2.17.0.
22
# If you modify this file, PreTeXt will no longer automatically update it.
33
#
44
# Boilerplate list of files in a PreTeXt project for git to ignore

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# This file was automatically generated with PreTeXt 2.17.0.
2+
pretext == 2.17.0

0 commit comments

Comments
 (0)