Skip to content

hotfixed regu PR

hotfixed regu PR #157

# Source version of this workflow lives in https://github.com/slds-lmu/lecture_service/service/.github/workflows
# Please only update by copying from there to avoid divergences
on:
# Allow manually triggering the workflow via GitHub website, gh CLI tool etc.
# Also adds parameter to enable tmate (inetractive tmux session for debugging)
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
push:
# Activate on pushes to both the main or master branches (inconsistently used across lecture repos)
branches: [main, master]
# ...but only if files in the slides folder change
paths: ['slides/**']
name: fix-figure-paths
jobs:
fix-figure-paths:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
# 0 indicates all history for all branches and tags, 1 is shallow (and default)
fetch-depth: 1
# Don't show progress bar, very verbose for large repos
show-progress: false
# Get a tmux ssh session for interactive debugging
# Controlled via inputs from GitHub webinterface
# See https://github.com/mxschmitt/action-tmate
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
- name: Fix figure paths in-place
run: |
sed -i -E "s\slides/[0-9a-z-]+/figure\figure\g" $(find slides -iname "*.tex")
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
title: "[Automated] Fix relative figure paths in slides/"
commit-message: "Fix figure paths"
body: |
Automated changes by `fix-figure-paths.yaml` workflow.
Compare and merge to keep figure paths compatible with compilation outside of overleaf.
## Explanation:
From what I understand, overleaf automatically tab-completes image paths relative to the project root, e.g.
`slides/supervised-regression/figure/nutshell-regression-poly-plot-1.pdf` - which is apparently fine on overleaf
but causes errors when trying to compile slides locally, where paths relative to the folder containing the
`.tex` file are required (i.e. `figure/nutshell-regression-poly-plot-1.pdf`).
As far as I understand it the latter path should also work on overleaf.
To locally auto-fix this, the following command can be used on Linux:
```sh
sed -i -E "s\slides/[0-9a-z-]+/figure\figure\g" $(find slides -iname "*.tex")
```
Which is exactly what this workflow does.
Note that macOS requires `gnu-sed` as the default BSD `sed` behaves differently.
branch: fix-figure-paths
add-paths: slides