|
| 1 | +name: LaTeX CI |
| 2 | + |
| 3 | +on: |
| 4 | +pull_request: |
| 5 | +branches: [ master ] |
| 6 | +push: |
| 7 | +branches: [ master ] |
| 8 | + |
| 9 | +jobs: |
| 10 | +changes: |
| 11 | +runs-on: ubuntu-latest |
| 12 | + |
| 13 | +outputs: |
| 14 | + matrix: ${{ steps.matrix.outputs.matrix }} |
| 15 | + |
| 16 | +steps: |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + with: |
| 19 | + fetch-depth: 0 |
| 20 | + |
| 21 | + - id: matrix |
| 22 | + shell: bash |
| 23 | + run: | |
| 24 | + DOCS=("bylaws" "policies" "board-procedures") |
| 25 | +
|
| 26 | + if [ "${{ github.event_name }}" = "pull_request" ]; then |
| 27 | + BASE_SHA="${{ github.event.pull_request.base.sha }}" |
| 28 | + else |
| 29 | + BASE_SHA="${{ github.event.before }}" |
| 30 | + fi |
| 31 | +
|
| 32 | + CHANGED=$(git diff --name-only "$BASE_SHA" "${{ github.sha }}") |
| 33 | +
|
| 34 | + SHARED_CHANGED=false |
| 35 | + for file in logo.png mathsoc.cls mathsoc.sty title.tex; do |
| 36 | + if echo "$CHANGED" | grep -q "^${file}$"; then |
| 37 | + SHARED_CHANGED=true |
| 38 | + break |
| 39 | + fi |
| 40 | + done |
| 41 | +
|
| 42 | + if [ "$SHARED_CHANGED" = true ]; then |
| 43 | + MATRIX='{"directory":["bylaws","policies","board-procedures"]}' |
| 44 | + else |
| 45 | + DIRS=() |
| 46 | +
|
| 47 | + for dir in "${DOCS[@]}"; do |
| 48 | + if echo "$CHANGED" | grep -q "^${dir}/"; then |
| 49 | + DIRS+=("\"${dir}\"") |
| 50 | + fi |
| 51 | + done |
| 52 | +
|
| 53 | + MATRIX="{\"directory\":[$(IFS=,; echo "${DIRS[*]}")]}" |
| 54 | + fi |
| 55 | +
|
| 56 | + echo "matrix=$MATRIX" >> "$GITHUB_OUTPUT" |
| 57 | +
|
| 58 | +build: |
| 59 | +needs: changes |
| 60 | + |
| 61 | +if: ${{ fromJson(needs.changes.outputs.matrix).directory[0] != null }} |
| 62 | + |
| 63 | +runs-on: ubuntu-latest |
| 64 | + |
| 65 | +strategy: |
| 66 | + fail-fast: false |
| 67 | + matrix: ${{ fromJson(needs.changes.outputs.matrix) }} |
| 68 | + |
| 69 | +container: |
| 70 | + image: ghcr.io/xu-cheng/texlive-full:latest |
| 71 | + |
| 72 | +steps: |
| 73 | + - uses: actions/checkout@v4 |
| 74 | + |
| 75 | + - name: Build ${{ matrix.directory }} |
| 76 | + run: | |
| 77 | + make -C "${{ matrix.directory }}" public |
| 78 | +
|
| 79 | + - name: Upload PDF |
| 80 | + uses: actions/upload-artifact@v4 |
| 81 | + with: |
| 82 | + name: ${{ matrix.directory }} |
| 83 | + path: ${{ matrix.directory }}/dist/*.pdf |
0 commit comments