-
Notifications
You must be signed in to change notification settings - Fork 107
72 lines (63 loc) · 2.16 KB
/
pdf_generation.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
70
71
72
name: PDF generation
on:
push:
branches:
- main
paths:
- '**.md'
- '**.json'
- '.github/workflows/pdf_generation.yml'
# Ignore Markdown files in the root
- '!*.md'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
fetch:
name: Generate PDF
runs-on: ubuntu-latest
steps:
- name: Install Linux packages
run: |
sudo apt update
sudo apt install -y git hub libpango-1.0-0 libharfbuzz0b libpangoft2-1.0-0 fonts-wqy-microhei
- name: Clone repository
uses: actions/checkout@v4
- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Python dependencies
run: |
pip install -r .github/requirements.txt
- name: Run generation script
run: |
# Set arbitrary EPOCH date to get reproducible PDF generation.
# https://github.com/Kozea/WeasyPrint/issues/1553
export SOURCE_DATE_EPOCH=1658210455
python .github/scripts/convert_to_pdf.py
- name: Set up git credentials
run : |
git config --global user.email '[email protected]'
git config --global user.name 'MozMEAO Bot'
- name: Commit changes to pdf_updates branch
continue-on-error: true
run: |
# Commit changes. Failure is allowed if there is nothing to commit.
git checkout -B pdf_updates
git add .
git commit -m "Convert documents to PDF"
git push -f origin pdf_updates
- name: Open pull request
continue-on-error: true
run: |
# continue-on-error is needed in case there is already an open PR
changes=$(git diff --name-only main pdf_updates -- | wc -l | awk '{print $1}')
if [[ "$changes" = "0" ]];
then
echo "No changes."
else
# Create pull request
hub pull-request -m "[pdf] Update documents in PDF format" -h pdf_updates -b main -r @mozilla/legal-l10n
fi
env:
GITHUB_TOKEN: ${{ secrets.L10N_LEGAL }}