www-from-model/.forgejo/workflows/register-depictions.yaml
Stephan Heunis d88ef5448c
All checks were successful
Deploy on webserver / Build site and deploy on success (push) Successful in 1m55s
process person depictions too
2026-06-02 12:13:14 +02:00

67 lines
2.8 KiB
YAML

name: Register depictions
on:
schedule:
- cron: '0 3 * * 1-5'
workflow_dispatch:
env:
DUMPTHINGS_APIURL: https://pool.psychoinformatics.de/api
jobs:
register_depictions:
runs-on: debian-latest
if: ${{ forgejo.repository == 'www/www-from-model' }}
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: Fetch python script
run: |
wget https://hub.psychoinformatics.de/orinoco/knowledge-enrichment/raw/branch/main/.forgejo/tools/get-depiction-urls.py
- name: Register depiction files
run: |
depiction_urls="$({
dtc get-records ${DUMPTHINGS_APIURL} public -C XYZPerson \
| qri filter-linked-pid --api-url ${DUMPTHINGS_APIURL} public xyzrins:. associated_with
dtc get-records ${DUMPTHINGS_APIURL} public -C XYZDataset
dtc get-records ${DUMPTHINGS_APIURL} public -C XYZInstrument
dtc get-records ${DUMPTHINGS_APIURL} public -C XYZObjective
dtc get-records ${DUMPTHINGS_APIURL} public -C XYZProject \
| qri filter-links-pid --link part_of xyzrins:. --recursive --collection public
dtc get-records ${DUMPTHINGS_APIURL} public -C XYZPublication
dtc get-records ${DUMPTHINGS_APIURL} public -C XYZTopic
} \
| qri inject-links-pid --link about depictions --class XYZDepiction \
| qri inline-records --api-url ${DUMPTHINGS_APIURL} -c public -p depictions::distributions \
| uv run get-depiction-urls.py \
-t xyzri:XYZPerson \
-t xyzri:XYZDataset \
-t xyzri:XYZInstrument \
-t xyzri:XYZObjective \
-t xyzri:XYZProject \
-t xyzri:XYZPublication \
-t xyzri:XYZTopic
)"
if [[ -n "$depiction_urls" ]]; 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..." && git restore --staged $targetfile && rm -f $targetfile)
done <<< "$depiction_urls"
git annex push
git annex push --cleanup
fi
- name: Deposit changes
uses: ./.forgejo/actions/deposit-changes