-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (53 loc) · 1.82 KB
/
generate-pdfs-on-release.yml
File metadata and controls
61 lines (53 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
name: Generate PDFs on Release
on:
release:
types: [created, published]
jobs:
generate-pdfs:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y pandoc texlive-xetex texlive-fonts-recommended texlive-plain-generic
sudo apt-get install -y poppler-utils
pip install jupyter==1.1.1 nbconvert==7.16.6
- name: Convert notebooks to PDF
run: |
mkdir -p pdfs
shopt -s nullglob
notebooks=(*.ipynb)
if [ ${#notebooks[@]} -eq 0 ]; then
echo "No notebooks found to convert"
exit 0
fi
for notebook in "${notebooks[@]}"; do
echo "Converting $notebook to PDF..."
jupyter nbconvert --to pdf "$notebook" --output-dir=pdfs || echo "Warning: Failed to convert $notebook"
done
# Merge all PDFs into one
echo "Merging PDFs..."
pdfunite pdfs/*.pdf pdfs/corso-python-basic.pdf
echo "Conversion complete! Final merged file: corso-python-basic.pdf"
- name: Upload PDFs to release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
shopt -s nullglob
pdfs=(pdfs/*.pdf)
if [ ${#pdfs[@]} -eq 0 ]; then
echo "No PDFs found to upload"
exit 0
fi
for pdf in "${pdfs[@]}"; do
echo "Uploading $pdf to release..."
gh release upload ${{ github.event.release.tag_name }} "$pdf" --clobber
done