CI test #65
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: Image metadata check CI | |
on: | |
# push: | |
# branches: [master] | |
pull_request: | |
paths: | |
- '**.webp' | |
- '**.png' | |
- '**.jpg' | |
jobs: | |
build: | |
name: Ubuntu - Image Metadata | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pull-requests: write | |
env: | |
# figured this out from here: https://docs.github.com/en/webhooks/webhook-events-and-payloads?actionType=edited#pull_request | |
SHA: ${{ github.event.pull_request.head.sha }} | |
BASE_SHA: ${{ github.event.pull_request.base.sha }} | |
steps: | |
- name: exiftool installation | |
run: | | |
sudo apt-get install --assume-yes exiftool | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# this makes the HEAD be the last commit on the PR, not the merge commit, so wrong older commits would get buried | |
# ref: ${{ github.event.pull_request.head.sha }} | |
- name: read/export image metadata | |
# -id: image_check | |
run: | | |
mapfile -t image_files < <(git diff --name-only ${BASE_SHA} ${SHA} | grep '\.webp$') | |
git status | |
# array of accepted copyright strings | |
accepted_cr=("GNU GPL v2+" "CC BY-SA 4.0") | |
# cycle through the changed image files, make sure they have the right fields | |
for file in "${image_files[@]}"; do | |
# check -Artist tag, fail if missing | |
artist="$(exiftool -Artist $file)" | |
artist="${artist#*: }" | |
if [ -z "$artist" ] ; then | |
echo "no Artist EXIF tag in $file" | |
exit 1 | |
else | |
echo "Artist tag in $file is $artist" | |
fi | |
# check -Copyright tag, fail if missing or wrong type | |
copyright="$(exiftool -Copyright $file)" | |
copyright="${copyright#*: }" | |
if [ -z "$copyright" ] ; then | |
echo "no Copyright EXIF tag in $file" | |
exit 1 | |
# elif [[ ( "$copyright" != ${accepted_cr[0]} ) && ( "$copyright" != ${accepted_cr[1]}) ]] ; then | |
elif [[ ! " ${accepted_cr[*]} " =~ " ${copyright} " ]]; then | |
echo "$copyright is not an accepted license" | |
exit 1 | |
else | |
echo "Copyright tag in $file is $copyright" | |
fi | |
done | |
# - name: The image_check step has failed | |
# if: ${{ failure() && steps.image_check.conclusion == 'failure' }} | |