Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 53 additions & 68 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,83 +1,68 @@
name: LaTeX CI

on:
pull_request:
branches: [ master ]
push:
branches: [ master ]
pull_request:
branches:
- master

jobs:
changes:
runs-on: ubuntu-latest

outputs:
matrix: ${{ steps.matrix.outputs.matrix }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- id: matrix
shell: bash
run: |
DOCS=("bylaws" "policies" "board-procedures")

if [ "${{ github.event_name }}" = "pull_request" ]; then
BASE_SHA="${{ github.event.pull_request.base.sha }}"
else
BASE_SHA="${{ github.event.before }}"
fi

CHANGED=$(git diff --name-only "$BASE_SHA" "${{ github.sha }}")

SHARED_CHANGED=false
for file in logo.png mathsoc.cls mathsoc.sty title.tex; do
if echo "$CHANGED" | grep -q "^${file}$"; then
SHARED_CHANGED=true
break
fi
done

if [ "$SHARED_CHANGED" = true ]; then
MATRIX='{"directory":["bylaws","policies","board-procedures"]}'
else
DIRS=()

for dir in "${DOCS[@]}"; do
if echo "$CHANGED" | grep -q "^${dir}/"; then
DIRS+=("\"${dir}\"")
fi
done
build:
runs-on: ubuntu-latest

container:
image: ghcr.io/xu-cheng/texlive-full:latest

MATRIX="{\"directory\":[$(IFS=,; echo "${DIRS[*]}")]}"
fi
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

echo "matrix=$MATRIX" >> "$GITHUB_OUTPUT"
- name: Mark workspace safe for git
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"

build:
needs: changes
- name: Determine changed documents
id: changed
shell: bash
run: |
# Fetch master so we have the ref to diff against
git fetch origin master --depth=1

if: ${{ fromJson(needs.changes.outputs.matrix).directory[0] != null }}
CHANGED=$(git diff --name-only origin/master...HEAD)

runs-on: ubuntu-latest
BUILD_BYLAWS=false
BUILD_POLICIES=false
BUILD_BOARD=false

strategy:
fail-fast: false
matrix: ${{ fromJson(needs.changes.outputs.matrix) }}
if echo "$CHANGED" | grep -Eq '^(logo\.png|mathsoc\.cls|mathsoc\.sty|title\.tex)$'; then
BUILD_BYLAWS=true
BUILD_POLICIES=true
BUILD_BOARD=true
fi

if echo "$CHANGED" | grep -q '^bylaws/'; then
BUILD_BYLAWS=true
fi

if echo "$CHANGED" | grep -q '^policies/'; then
BUILD_POLICIES=true
fi

if echo "$CHANGED" | grep -q '^board-procedures/'; then
BUILD_BOARD=true
fi

container:
image: ghcr.io/xu-cheng/texlive-full:latest
echo "bylaws=$BUILD_BYLAWS" >> $GITHUB_OUTPUT
echo "policies=$BUILD_POLICIES" >> $GITHUB_OUTPUT
echo "board=$BUILD_BOARD" >> $GITHUB_OUTPUT

steps:
- uses: actions/checkout@v4
- name: Build bylaws
if: steps.changed.outputs.bylaws == 'true'
run: make -C bylaws public

- name: Build ${{ matrix.directory }}
run: |
make -C "${{ matrix.directory }}" public
- name: Build policies
if: steps.changed.outputs.policies == 'true'
run: make -C policies public

- name: Upload PDF
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.directory }}
path: ${{ matrix.directory }}/dist/*.pdf
- name: Build board-procedures
if: steps.changed.outputs.board == 'true'
run: make -C board-procedures public
139 changes: 81 additions & 58 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,65 +1,88 @@
name: Publish PDFs

on:
push:
branches:
- master

permissions:
contents: read
pages: write
id-token: write
push:
branches:
- master

concurrency:
group: pages
cancel-in-progress: true
group: pages
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest

container:
image: ghcr.io/xu-cheng/texlive-full:latest

steps:
- uses: actions/checkout@v4

- name: Build bylaws
run: make -C bylaws public

- name: Build policies
run: make -C policies public

- name: Build board-procedures
run: make -C board-procedures public

- name: Prepare Pages content
run: |
mkdir site

cp bylaws/dist/*.pdf site/
cp policies/dist/*.pdf site/
cp board-procedures/dist/*.pdf site/

- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: site

deploy:
needs: build

runs-on: ubuntu-latest

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

permissions:
pages: write
id-token: write

steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
deploy:
runs-on: ubuntu-latest

permissions:
contents: read
pages: write
id-token: write
actions: read

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

steps:
- uses: actions/checkout@v4

- name: Download PDFs from latest CI run
id: download
uses: dawidd6/action-download-artifact@v6
with:
name: generated-pdfs
workflow: ci.yml
branch: master
path: artifacts/
if_no_artifact_found: warn

- name: Check PDFs were downloaded
id: check
run: |
COUNT=$(find artifacts/ -name "*.pdf" 2>/dev/null | wc -l)
echo "pdf_count=$COUNT" >> $GITHUB_OUTPUT
if [ "$COUNT" -eq 0 ]; then
echo "No PDFs found — nothing to publish."
fi

- name: Prepare site
if: steps.check.outputs.pdf_count != '0'
run: |
mkdir -p site

# Flatten PDFs from nested dist/ dirs into site root
find artifacts/ -name "*.pdf" -exec cp {} site/ \;

# Generate index page
cat > site/index.html << 'EOF'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Documents</title>
<style>
body { font-family: sans-serif; max-width: 600px; margin: 2rem auto; padding: 0 1rem; }
a { display: block; margin: .5rem 0; }
</style>
</head>
<body>
<h1>Documents</h1>
EOF

for pdf in site/*.pdf; do
name=$(basename "$pdf")
echo "<a href=\"$name\">$name</a>" >> site/index.html
done

echo "</body></html>" >> site/index.html

- name: Upload Pages artifact
if: steps.check.outputs.pdf_count != '0'
uses: actions/upload-pages-artifact@v3
with:
path: site

- name: Deploy to GitHub Pages
if: steps.check.outputs.pdf_count != '0'
id: deployment
uses: actions/deploy-pages@v4
Loading