www.trr379.de/.forgejo/workflows/register-depictions.yml
Stephan Heunis daa9614be5
All checks were successful
Deploy on webserver / Build site and deploy on success (push) Successful in 4m31s
fix double wget error
2026-05-28 13:28:07 +02:00

62 lines
2.3 KiB
YAML

name: Register depictions
on:
schedule:
- cron: '0 3 * * 1-5'
workflow_dispatch:
env:
DUMPTHINGS_APIURL: https://pool.v0.trr379.de/api
jobs:
register_depictions:
runs-on: debian-latest
if: ${{ forgejo.repository == 'q04/www.trr379.de' }}
outputs:
committed: ${{ steps.commit.outputs.committed }}
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Prepare environment
uses: ./.forgejo/actions/prep-metadata-query
- name: git-annex init
run: |
git fetch --depth 1 origin git-annex:git-annex
git config --add annex.private true
git annex init
- name: Install jq
run: |
apt-get update
apt-get install -y jq
- name: Fetch python script
run: |
wget https://hub.trr379.de/q04/www.trr379.de/raw/branch/main/.forgejo/tools/get-depiction-urls.py
- name: Register depiction files
run: |
person_pids_from_projects="$(
dtc get-records ${DUMPTHINGS_APIURL} public -C TRR379Project \
| jq -r '.associated_with[]?.object' \
| grep 'trr379root:contributors' \
| sort -u
)"
output="$(
dtc get-records ${DUMPTHINGS_APIURL} public --class TRR379Person \
| grep -F -f <(printf '%s\n' "$person_pids_from_projects") \
| qri inject-links-pid --link about depictions --class TRR379Depiction \
| qri inline-records --api-url ${DUMPTHINGS_APIURL} -c public -p depictions::distributions \
| uv run get-depiction-urls.py
)"
if [[ -n "$output" ]]; then
while IFS=$'\t' read -r depiction_type curie ext url; do
export targetfile="content/${curie}/${depiction_type}.${ext}"; \
echo "Register $targetfile" ; \
test -e "$targetfile" && git rm -f "$targetfile"; \
(git annex addurl --raw --relaxed --file="$targetfile" "$url" && git annex get "$targetfile") || \
echo "addurl failed for $url, continuing..."
done <<< "$output"
git annex push
git annex push --cleanup
fi
- name: Deposit changes
uses: ./.forgejo/actions/deposit-changes