Update README.md with the link to the PDF file #64
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build PDF document | |
on: | |
push: | |
branch: | |
- master | |
workflow_dispatch: | |
jobs: | |
build-pdf: | |
runs-on: ubuntu-latest | |
steps: | |
- name: check out code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo | |
- name: install ubuntu dependencies | |
run: | | |
sudo apt -y update | |
sudo apt -y install gnuplot | |
- name: Set up python3 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
cache: 'pip' # caching pip dependencies | |
- name: install python3 dependencies | |
run: | | |
pip install -r requirements.txt | |
pip install setuptools | |
- name: setup texlive | |
uses: teatimeguest/setup-texlive-action@v3 | |
with: | |
version: 2024 | |
packages: | | |
# to list local packages use: tlmgr info --list --data name | |
scheme-basic | |
latexmk | |
cmap | |
cancel | |
tex-gyre | |
fncychap | |
float | |
wrapfig | |
capt-of | |
framed | |
babel-polish | |
fancyvrb | |
upquote | |
needspace | |
tabulary | |
varwidth | |
booktabs | |
parskip | |
titlesec | |
etoolbox | |
makecell | |
caption | |
- name: build PDF | |
run: make latexpdf | |
- name: extract file name | |
run: | | |
# extract filename from conf.py (it is a value of variable 'project' in lowercase) | |
echo "filename=$(grep project conf.py | gawk '{gsub(/'\''/,"",$3); print tolower($3)}')" >> $GITHUB_ENV | |
- name: do some trick ;-) | |
shell: bash | |
run: | | |
echo "The file name is $filename" | |
stat "_build/latex/${filename}.pdf" | |
mv "_build/latex/${filename}.pdf" .. | |
rm -rf * | |
git add . | |
git config user.name gucio321 | |
git config user.email [email protected] | |
mv ../${filename}.pdf . | |
git add . | |
git commit --amend --no-edit | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: pdf | |
force: true | |
update-url: | |
needs: [build-pdf] | |
runs-on: ubuntu-latest | |
steps: | |
- name: check out code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo | |
- name: extract file name | |
run: | | |
# extract filename from conf.py (it is a value of variable 'project' in lowercase) | |
echo "filename=$(grep project conf.py | gawk '{gsub(/'\''/,"",$3); print tolower($3)}')" >> $GITHUB_ENV | |
- name: edit README | |
run: | | |
# replace content of README.md between <!--AUTOURL-BEGIN--> and <!--AUTOURL-END--> with the link to the PDF file | |
sed -i -e "/\(<\!--AUTOURL-BEGIN-->\)/, /\(<\!--AUTOURL-END-->\)/c\<\!--AUTOURL-BEGIN-->\n<a href=\"https://github.com/${{ github.repository }}/blob/pdf/$filename.pdf\">\n<\!--AUTOURL-END-->" README.md | |
- name: commit | |
run: | | |
git config user.name gucio321 | |
git config user.email [email protected] | |
git add README.md | |
git commit -m "Update README.md with the link to the PDF file" | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ github.ref }} | |
force: true | |