Skip to content

Add error handling if queue has content not know by the client #27

Add error handling if queue has content not know by the client

Add error handling if queue has content not know by the client #27

name: Image metadata check CI
on:
push:
branches: [ master ]
paths: [ '**.webp', '**.png', '**.jpg', '**.jpeg' ]
pull_request:
paths: [ '**.webp', '**.png', '**.jpg', '**.jpeg' ]
permissions:
contents: read
jobs:
build:
name: Image Metadata
runs-on: ubuntu-latest
env:
BASE_SHA: ${{ github.event_name == 'push' && github.event.before || 'HEAD^' }}
HEAD_SHA: ${{ github.event_name == 'push' && github.event.after || 'HEAD' }}
steps:
- name: exiftool installation
run: |
sudo apt-get install --assume-yes exiftool
- uses: actions/checkout@v6
with:
fetch-depth: 0
env:
_debug: ${{ toJSON(github) }}
- name: check image metadata
run: |
git log --graph --pretty=format:'%h %G?%d %s (%cr) <%an> (%cn)' "$BASE_SHA^".."$HEAD_SHA"
mapfile -t png_files < <(git diff --name-only --diff-filter=d "$BASE_SHA" "$HEAD_SHA" -- '*.png')
mapfile -t jpg_files < <(git diff --name-only --diff-filter=d "$BASE_SHA" "$HEAD_SHA" -- '*.jpg' '*.jpeg')
mapfile -t webp_files < <(git diff --name-only --diff-filter=d "$BASE_SHA" "$HEAD_SHA" -- '*.webp')
printf '\n\nmetadata of all changed files:\n'
((${#png_files[@]} > 0)) && exiftool -q -f \
-p '$Directory/$FileName' \
-p $'PNG:\tCreateDate=$PNG:CreateDate,ModifyDate=$PNG:ModifyDate,Copyright=$PNG:Copyright,Artist=$PNG:Artist' \
-p $'EXIF:\tCreateDate=$EXIF:CreateDate,ModifyDate=$EXIF:ModifyDate,Copyright=$EXIF:Copyright,Artist=$EXIF:Artist' \
-p $'XMP:\tCreateDate=$XMP:CreateDate,ModifyDate=$XMP:ModifyDate,Rights=$XMP:Rights,Creator=$XMP:Creator' \
-p 'UserComment=$UserComment' \
-p '' -- "${png_files[@]}"
((${#jpg_files[@]} + ${#webp_files[@]} > 0)) && exiftool -q -f \
-p '$Directory/$FileName' \
-p $'EXIF:\tCreateDate=$EXIF:CreateDate,ModifyDate=$EXIF:ModifyDate,Copyright=$EXIF:Copyright,Artist=$EXIF:Artist' \
-p $'XMP:\tCreateDate=$XMP:CreateDate,ModifyDate=$XMP:ModifyDate,Rights=$XMP:Rights,Creator=$XMP:Creator' \
-p 'UserComment=$UserComment' \
-p '' -- "${jpg_files[@]}" "${webp_files[@]}"
checktag() {
tag=$(exiftool -m -p "\$$1" "$2")
[ "$tag" ] || { printf '%s: %s tag is missing or empty!\n' "$2" "$1"; return 1; }
}
checkrights() {
tag=$(exiftool -m -p "\$$1" "$2")
case $tag in
'GNU GPL v2+'|'CC BY-SA 4.0'|CC0) return 0;;
*) printf '%s: %s tag (%s) must contain one of: "GNU GPL v2+", "CC BY-SA 4.0", "CC0"\n' "$2" "$1" "$tag"; return 1;;
esac
}
return=0
# cycle through the changed image files, make sure they have the right fields
for file in "${jpg_files[@]}" "${webp_files[@]}" "${png_files[@]}"; do
checktag EXIF:Artist "$file" || return=1
checkrights EXIF:Copyright "$file" || return=1
done
exit "$return"