Chore: Move dependancy setup to a single step. #337
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: Documentation Build | |
on: | |
push: | |
pull_request: | |
env: | |
MARKDOWN_DIR: ./.github/workflows/bin/markdown | |
TEMP_DIR: ./.github/workflows/bin/temp | |
PDF_DIR: ./.github/workflows/bin/pdf | |
IMAGES_DIR: ./images | |
MAIN_FONT: "Source Sans Pro" | |
jobs: | |
check-spelling: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Check Spelling | |
uses: rojopolis/[email protected] | |
with: | |
config_path: .spellcheck.yml | |
task_name: Markdown | |
build-pdf: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y powershell imagemagick ghostscript | |
- name: Cache APT Packages | |
uses: actions/cache@v4 | |
with: | |
path: /var/cache/apt | |
key: ${{ runner.os }}-apt-cache | |
restore-keys: ${{ runner.os }}-apt-cache | |
- name: Create output paths | |
run: mkdir -p $TEMP_DIR $MARKDOWN_DIR $PDF_DIR | |
- name: Run PowerShell script | |
shell: pwsh | |
run: | | |
./scripts/Merge-MarkdownFiles.ps1 | |
- name: Fix logo and copy images to root directory for pandoc # images directory is deleted in "Cleanup temporary items" step | |
run: | | |
cp -r ./.github/workflows/bin/markdown/images ./images | |
sed -i '/!\[\](images\/qlcplus\.svg)/d' ./.github/workflows/bin/markdown/qlcplus-docs.md | |
- name: Normalize image DPI | |
run: | | |
for file in ./images/*.{jpg,jpeg,png,tiff,bmp}; do | |
if [[ -f "$file" ]]; then | |
convert "$file" -units PixelsPerInch -density 96 "$file" | |
echo "Processed $file" | |
fi | |
done | |
- name: Install GitHub CLI | |
run: sudo apt-get install gh | |
- name: Fetch Latest Release | |
id: get_release | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Set the token for GitHub CLI authentication | |
run: | | |
RELEASE=$(gh release view --json tagName --jq .tagName) | |
echo "LATEST_RELEASE=$RELEASE" >> $GITHUB_ENV | |
- name: Put current date into a variable | |
run: | | |
echo "EXPORT_DATE=$(date --rfc-3339=date)" >> ${GITHUB_ENV} | |
- name: Build PDF | |
uses: docker://pandoc/extra | |
with: | |
args: > | |
-s -o ./.github/workflows/bin/temp/QLCplusDocumentation.pdf | |
./.github/workflows/bin/markdown/qlcplus-docs.md | |
--listings | |
--pdf-engine=lualatex | |
-V papersize=a4 | |
-V geometry:margin=1.5cm | |
-V classoption=oneside | |
-V indent=false | |
-V toc=true | |
-V toc-title="Table of Contents" | |
-V mainfont="Source Sans Pro" | |
-V sansfont="Source Sans Pro" | |
-f markdown-raw_tex | |
- name: Create Title Page Markdown | |
run: | | |
echo '{ style="width: 50%; margin: auto;" }' >> ./.github/workflows/bin/temp/titlepage.md | |
- name: Convert Title Page to PDF | |
uses: docker://pandoc/extra | |
with: | |
args: > | |
-s -o ./.github/workflows/bin/temp/titlepage.pdf | |
./.github/workflows/bin/temp/titlepage.md | |
--pdf-engine=lualatex | |
--template=./scripts/template.tex | |
--verbose | |
-V mainfont="Source Sans Pro" | |
-V sansfont="Source Sans Pro" | |
-V title="Q Light Controller + Documentation" | |
-V subtitle="Comprehensive Guide" | |
-V author="docs.qlcplus.org" | |
-V date="${{env.EXPORT_DATE}}" | |
-V release="${{env.LATEST_RELEASE}}" | |
- name: Combine Title Page and Documentation PDFs | |
run: | | |
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=./.github/workflows/bin/pdf/qlcplus-docs.pdf ./.github/workflows/bin/temp/titlepage.pdf ./.github/workflows/bin/temp/QLCplusDocumentation.pdf | |
- name: Cleanup temporary items | |
run: | | |
rm -rf ./.github/workflows/bin/temp/ | |
rm -rf ./.github/workflows/bin/images/ | |
- name: Upload-PDF | |
uses: actions/upload-artifact@v4 | |
with: | |
name: qlcplus-docs-en-pdf | |
path: ./.github/workflows/bin/pdf/ | |
- name: Upload-Markdown | |
uses: actions/upload-artifact@v4 | |
with: | |
name: qlcplus-docs-en-markdown | |
path: ./.github/workflows/bin/markdown/ |