-
Notifications
You must be signed in to change notification settings - Fork 186
69 lines (58 loc) · 1.98 KB
/
pdf.yml
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
62
63
64
65
66
67
68
69
name: Docs to PDF
on:
push:
branches:
- main
pull_request:
types:
- closed
branches:
- main
workflow_dispatch: {}
jobs:
converttopdf:
name: build-release-pdf
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true || github.event_name == 'push' || github.event_name == 'workflow_dispatch'
steps:
- id: today
run: echo "name=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
# Checkout the repository
- uses: actions/checkout@v3
# Install pandoc and xelatex
- name: Install dependencies
run: sudo apt-get install -y pandoc texlive-xetex
# Create directory for PDFs
- name: Create PDF directory
run: mkdir -p pdfs
# Fix YAML metadata issues
- name: Fix YAML metadata
run: |
find . -name "*.md" -exec sed -i '/^---$/!b;n;/^$/!b;n;/^---$/d;' {} \;
# Ensure images are present
- name: Ensure images are present
run: mkdir -p imgs && touch imgs/dummy.jpg
- name: Replace missing images
run: |
find . -name "*.md" -exec sed -i 's|imgs/|imgs/dummy.jpg|g' {} \;
# Concatenate all markdown files into a single file
- name: Concatenate markdown files
run: find . -name "*.md" -exec cat {} + > combined.md
# Convert the concatenated markdown to PDF using xelatex and custom template
- name: Convert markdown to PDF
run: pandoc combined.md -o pdfs/combined.pdf --pdf-engine=xelatex --template=template.tex
# Upload the PDF artifact
- uses: actions/upload-artifact@v3
with:
name: release
path: pdfs
# Create a release with the PDF
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: release-${{ env.name }}
release_name: release-${{ env.name }}
draft: false
prerelease: false
files: pdfs/combined.pdf