Image metadata CI check (#9222)

add image exif metadata check workflow to CI (checks PR images only)
This commit is contained in:
doofus-01 2024-08-24 04:07:31 -07:00 committed by GitHub
parent 01806d090f
commit 78a4c5c494
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

68
.github/workflows/image_metadata.yml vendored Normal file
View file

@ -0,0 +1,68 @@
name: Image metadata check CI
on:
#push:
# branches: [master]
pull_request:
paths:
- '**.webp'
- '**.png'
- '**.jpg'
- '**.jpeg'
jobs:
build:
name: Ubuntu - Image Metadata
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
env:
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
- name: read/export image metadata
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
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' }}