Skip to content

Update check-and-ebook.yml #10

Update check-and-ebook.yml

Update check-and-ebook.yml #10

# This workflow runs upon new commits (check and make) and PRs (check only)
name: Check and Make eBook
on:
workflow_dispatch:
push:
branches: ["main"]
pull_request:
branches: ["main"]
# permissions:
# contents: read
jobs:
#
# check source code
#
check:
runs-on: ubuntu-22.04
steps:
- name: checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 1 # 0 if you want to push to repo
- name: python set up
uses: actions/setup-python@v5
with:
python-version: "3.10"
# cache: "pip"
- name: python cache set up
uses: actions/cache@v4
with:
path: ${{ env.pythonLocation }}
key: python-${{ env.pythonLocation }}
- name: check chapters for known issues
run: python3 -O scripts/check_chapters.py
- name: check pre-commit hooks
uses: pre-commit/[email protected]
#
# make eBook
#
make:
needs: check
# do not run make for pull_requests
if: github.event_name != 'pull_request'
runs-on: ubuntu-22.04
steps:
- name: checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 1 # 0 if you want to push to repo
- name: calculate hash of date + chapters/*.tex
id: calculate-hash
run: |
current_date=$(date -u '+%Y-%m-%d')
hash=$(md5sum chapters/*.tex)
echo "::set-output name=hash::"${current_date}_${hash}"
- name: Cache lookup
id: cache
uses: actions/cache@v2
with:
path: ~/.cache
key: ${{ runner.os }}-hash-${{ steps.calculate-hash.outputs.hash }}
- name: Check if hash has changed
id: check-hash
run: |
if [[ -z "${{ steps.cache.outputs.cache-hit }}" ]]; then
echo "Hash changed. Proceeding with the workflow."
else
echo "Hash unchanged. Exiting the workflow."
exit 0
fi
- name: python set up
uses: actions/setup-python@v5
with:
python-version: "3.10"
# cache: "pip"
# - name: setup environment to DE lang
# run: |
# cd /usr/share/locales
# sudo ./install-language-pack de_DE.UTF-8
- name: ls before
run: |
pwd
ls -l
- name: install apt packages using cache
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: texlive-extra-utils pandoc calibre imagemagick ghostscript
version: 1.0
# execute_install_scripts: true
- name: print versions
run: |
cat /etc/os-release
# xelatex -v
# latexmk -v
calibre --version
pandoc --version
python3 --version
- name: make eBooks
run: |
wget --quiet https://github.com/entorb/hpmor-de/releases/download/WorkInProgress/hpmor.pdf -O hpmor.pdf
sh scripts/make_ebooks.sh > /dev/null
- name: ls after
run: |
pwd
ls -l
- name: publish eBooks to release
uses: softprops/action-gh-release@v2
with:
tag_name: WorkInProgress
prerelease: true
files: |
./hpmor.docx
./hpmor.html
./hpmor.epub
./hpmor.mobi
./hpmor.fb2