Skip to content

Merge pull request #41 from gehuhaldwani/upload-1736931021025 #13

Merge pull request #41 from gehuhaldwani/upload-1736931021025

Merge pull request #41 from gehuhaldwani/upload-1736931021025 #13

Workflow file for this run

name: Generate Thumbnails
on:
workflow_dispatch:
push:
branches:
- main
concurrency:
group: "thumbnails"
cancel-in-progress: true
jobs:
generate:
permissions:
contents: write
runs-on: ubuntu-24.04
steps:
- name: Checkout main branch to pyqs
uses: actions/checkout@v4
with:
ref: main
- name: Install ImageMagick
run: sudo apt-get install -y imagemagick
- name: Generate Thumbnails
run: |
# Set the output thumbnail size
THUMBNAIL_SIZE="512x512"
# Create an output directory for thumbnails (optional)
OUTPUT_DIR="thumbnails"
mkdir -p "$OUTPUT_DIR"
# Find all PDF files in the current directory and its subdirectories
find . -type f -name "*.pdf" | while read -r pdf_file; do
# Extract the base filename and directory path
base_name=$(basename "$pdf_file" .pdf)
dir_name=$(dirname "$pdf_file")
# Create a corresponding subdirectory structure in the output directory
output_subdir="$OUTPUT_DIR/$dir_name"
mkdir -p "$output_subdir"
(
# Convert the first page of the PDF to a .webp thumbnail
convert -thumbnail "$THUMBNAIL_SIZE" "$pdf_file"[0] "$output_subdir/$base_name.webp"
# Notify the user
echo "Converted $pdf_file to $output_subdir/$base_name.webp"
) &
done
wait
echo "All PDF files have been converted to .webp thumbnails."
- name: push thumbnails to the output branch
uses: crazy-max/[email protected]
with:
target_branch: thumbnails
build_dir: thumbnails
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}