Skip to content

Commit

Permalink
Breakout the GitHub Actions workflow in run-gen-index.yml to three ne…
Browse files Browse the repository at this point in the history
…w files

The three new actions are:
1. extract-images.yml: Extract new images to be used as thumnails in the gallery, when new editions of the "filosoof" get added to the pdf directory (pdfs beginning with a number). Extract these images from the coverpages of the PDF.
2. regenerate-index.yml: Regenerate `index.html` when `template.html` gets alltered.
3. regenerate-gallery.yml: Regenerate the "galllery" that gets inserted into `index.html` when a .png file beginning with a number gets added (by another action) to the /img directory.

These workflows should make updating the "filosoof" website basically automatic.
  • Loading branch information
PSJ-Sokolov committed Mar 18, 2024
1 parent 9cade18 commit 5e71e4a
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 30 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/extract-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Extract the coverpages from the pdfs in ./pdf, as images, save then in ./img, so that we can use them as thumbnails in the gallery in 'index.html'.
name: extract_coverpages

on:
push:
paths:
- 'pdf/[0-9]*.pdf'

jobs:
extract-coverpages:
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
echo "Installing and upgrading pip..."
python -m pip install --upgrade pip
echo "Installing pdf2image..."
pip install pdf2image # For extracting coverpages

- name: Extract coverpages run python script
run: python3 extract-humbnails.py

- name: Commit and push changes
run: |
git config --local user.email "
git config --local user.name "GitHub Action"
git add img
git commit -m "[CI/CD] Extract coverpages"
git push
30 changes: 30 additions & 0 deletions .github/workflows/regenerate-gallery.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Deze file zou de `index.html` aan moeten passen, als de nieuwe thumbnails geextraheerd zijn.

on:
push:
paths:
- 'img/[0-9]*.png'

jobs:
add-new-thumbnails-to-gallery:
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Update index.html with new images.
run: |
echo "Updating index.html with new images."
python3 generate-index.py
- name: Commit changes
run: |
git config --local user.email "
git config --local user.name "GitHub Action"
git add index.html
git commit -m "[CI/CD] Update index.html with new images"
git push
31 changes: 31 additions & 0 deletions .github/workflows/regnerate-index.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Deze action zou moeten draaien als de template.html wordt aangepast, zodat de nieuwe info er komt te staan.
name: Update from 'template.html'

on:
push:
paths:
- 'template.html'

jobs:
update-index-html-from-template-html:
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Update index.html from new template.html
run: |
echo "Updating index.html from new template.html"
python3 generate-index.py
- name: Commit changes
run: |
git config --local user.email "
git config --local user.name "GitHub Action"
git add index.html
git commit -m "[CI/CD] Update index.html from new template.html"
git push
30 changes: 0 additions & 30 deletions .github/workflows/run-gen-index-img.yml

This file was deleted.

0 comments on commit 5e71e4a

Please sign in to comment.