Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/committee-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: "Generate committee mini images"

on:
pull_request:
branches: [main]
paths:
- 'assets/committee/*/full/**'

concurrency:
group: committee-images-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
minify:
# GITHUB_TOKEN can't push to forks, so only run for branches in this repo
if: github.repository == github.event.pull_request.head.repo.full_name
permissions:
contents: write

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
filter: blob:none

- name: Install ImageMagick
run: sudo apt-get update && sudo apt-get install -y imagemagick

- name: Run committee.sh on each changed committee folder
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
run: |
git -c core.quotePath=false diff --name-only --no-renames --diff-filter=d "$BASE_SHA"...HEAD -- 'assets/committee/*/full/*' \
| cut -d/ -f1-3 | sort -u \
| while read -r dir; do
# Skip if the minis were already committed after the last full image change (e.g. made locally)
last_full=$(git log -1 --format=%H "$BASE_SHA"..HEAD -- "$dir/full")
last_mini=$(git log -1 --format=%H "$BASE_SHA"..HEAD -- "$dir/mini")
if [ -n "$last_mini" ] && git merge-base --is-ancestor "$last_full" "$last_mini"; then
echo "Mini images for $dir are already up to date"
continue
fi

echo "Generating mini images for $dir"
_scripts/committee.sh "$dir"

# committee.sh doesn't report convert failures, so check each full image has a mini
for full in "$dir"/full/*; do
if [ ! -f "$dir/mini/$(basename "$full")" ]; then
echo "::error file=$full::No mini image was made for $full"
exit 1
fi
done
done

- name: Commit mini images to the PR
env:
HEAD_REF: ${{ github.event.pull_request.head.ref }}
run: |
git add -A assets/committee
if git diff --cached --quiet; then
echo "Mini images are already up to date"
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git commit -m "Generate committee mini images"
git push origin "HEAD:refs/heads/$HEAD_REF"
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,14 @@ and dates given in the calendar event. The below table details the process:

To update the committee:

1. Add the new committee's photos into `assets/committee/full`
1. Add the new committee's photos into `assets/committee/<year>/full`, e.g. `assets/committee/2026-27/full`
- Each image should have a 1:1 ratio.
- Add the highest quality images you can (they'll be scaled down later).
- Most common image formats are supported.
2. Create all the additional files by running `_scripts/committee.sh _scripts/assets/committee/2019-20`
(it's a bash shell script).
2. You don't need to make the smaller images in `assets/committee/<year>/mini` yourself. When you open a pull request,
a workflow makes them and commits them to your branch, so run `git pull` before pushing more changes.
- To make them yourself instead, run `_scripts/committee.sh assets/committee/2026-27`
(it's a bash shell script and needs ImageMagick).
3. Create a new yaml file in `_data/committee/` with these tags:
- `academic_year`: The academic year of the committee, e.g. `2019/20`
- `prefix`: Prefix to the role of each member, e.g. \"`Outgoing` Publicity Rep\"
Expand Down
4 changes: 4 additions & 0 deletions _scripts/committee.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ done

resolution="250x250"

# Stop ImageMagick saving timestamps in the images, so remaking an image gives
# an identical file. Must be above 0 for ImageMagick 7.
export SOURCE_DATE_EPOCH=1

mkdir -p $committee/mini/

find "$committee/full/" -type f -print0 | while IFS= read -r -d '' picture; do
Expand Down
Loading