|
| 1 | +name: Build CV |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + - 'documents/JRM_CV.tex' |
| 9 | + - 'scripts/build_cv.py' |
| 10 | + - 'scripts/extract_cv.py' |
| 11 | + - 'css/cv.css' |
| 12 | + - '.github/workflows/build-cv.yml' |
| 13 | + pull_request: |
| 14 | + branches: |
| 15 | + - main |
| 16 | + paths: |
| 17 | + - 'documents/JRM_CV.tex' |
| 18 | + - 'scripts/build_cv.py' |
| 19 | + - 'scripts/extract_cv.py' |
| 20 | + - 'css/cv.css' |
| 21 | + - '.github/workflows/build-cv.yml' |
| 22 | + workflow_dispatch: # Allow manual triggering |
| 23 | + |
| 24 | +jobs: |
| 25 | + build-cv: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + |
| 28 | + steps: |
| 29 | + - name: Checkout repository |
| 30 | + uses: actions/checkout@v4 |
| 31 | + |
| 32 | + - name: Install TeX Live |
| 33 | + run: | |
| 34 | + sudo apt-get update |
| 35 | + sudo apt-get install -y texlive-xetex texlive-fonts-extra texlive-latex-extra |
| 36 | +
|
| 37 | + - name: Install Dartmouth Ruzicka font |
| 38 | + run: | |
| 39 | + mkdir -p ~/.fonts |
| 40 | + cp data/DartmouthRuzicka-*.ttf ~/.fonts/ |
| 41 | + fc-cache -fv |
| 42 | +
|
| 43 | + - name: Set up Python |
| 44 | + uses: actions/setup-python@v5 |
| 45 | + with: |
| 46 | + python-version: '3.11' |
| 47 | + cache: 'pip' |
| 48 | + cache-dependency-path: 'requirements-build.txt' |
| 49 | + |
| 50 | + - name: Install Python dependencies |
| 51 | + run: pip install -r requirements-build.txt |
| 52 | + |
| 53 | + - name: Build CV (PDF and HTML) |
| 54 | + working-directory: scripts |
| 55 | + run: python build_cv.py |
| 56 | + |
| 57 | + - name: Run CV tests |
| 58 | + run: python -m pytest tests/test_build_cv.py -v |
| 59 | + |
| 60 | + - name: Check for changes |
| 61 | + id: check_changes |
| 62 | + run: | |
| 63 | + if [[ -n $(git status --porcelain documents/JRM_CV.pdf documents/JRM_CV.html) ]]; then |
| 64 | + echo "changes=true" >> $GITHUB_OUTPUT |
| 65 | + else |
| 66 | + echo "changes=false" >> $GITHUB_OUTPUT |
| 67 | + fi |
| 68 | +
|
| 69 | + - name: Commit and push changes |
| 70 | + if: github.event_name == 'push' && steps.check_changes.outputs.changes == 'true' |
| 71 | + run: | |
| 72 | + git config user.name 'github-actions[bot]' |
| 73 | + git config user.email 'github-actions[bot]@users.noreply.github.com' |
| 74 | + git add documents/JRM_CV.pdf documents/JRM_CV.html |
| 75 | + git diff --staged --quiet || git commit -m "Auto-build: Update CV PDF and HTML from LaTeX source" |
| 76 | + git push |
0 commit comments