Add all components allowing person depiction registration workflow #27

Merged
mih merged 2 commits from depiction-workflow into main 2026-03-31 10:52:55 +00:00
3 changed files with 83 additions and 0 deletions

View file

@ -0,0 +1,9 @@
runs:
using: "composite"
steps:
- name: Deposit changes
run: |
git add content
git diff --quiet --cached \
&& echo "Already up-to-date" \
|| ( git commit -m "chore: auto-generate content from metadata" && git push origin )

View file

@ -0,0 +1,25 @@
runs:
using: "composite"
steps:
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Install tools
run: |
# use a single environment for all tools
uv tool install https://hub.psychoinformatics.de/orinoco/query-things.git \
--with-executables-from dump-things-pyclient \
--with-executables-from git-annex
# we need git-annex even when we are not working with annex keys
# the repository is annex-init'ed on-clone, so git-annex tooling
# runs in commit hooks
- name: Prepare Git
run: |
git config --global user.name "Forgejo Actions"
git config --global user.email ${{ forgejo.actor }}@${FORGEJO_SERVER_URL#*://}
git config --global credential.helper cache
git credential approve <<EOF
url=${{ forgejo.server_url }}
username=${{ forgejo.actor }}
password=${{ forgejo.token }}
EOF
echo OK

View file

@ -0,0 +1,49 @@
name: Register person 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: Fetch python script
run: |
wget https://hub.psychoinformatics.de/orinoco/knowledge-enrichment/raw/branch/main/.forgejo/tools/get-person-depiction-urls.py
- name: Register depiction files
run: |
jq_output="$(
dtc get-records ${DUMPTHINGS_APIURL} public -C TRR379Person \
| qri filter-linked-pid --api-url ${DUMPTHINGS_APIURL} public trr379root:. associated_with \
| qri inject-links-pid --link about depictions --class TRR379Depiction \
| qri inline-records --api-url ${DUMPTHINGS_APIURL} -c public -p depictions::distributions \
| uv run get-person-depiction-urls.py --target-class 'trr379ri:TRR379Person' --depiction-type 'trr379:depiction-types/e9a34f7d-d05e-4591-bb45-f8a0c499e07b'
)"
if [[ -n "$jq_output" ]]; then
while IFS=$'\t' read -r curie ext url; do
git annex addurl --file="content/${curie}/portrait.${ext}" "$url" || \
echo "addurl failed for $url, continuing..."
done <<< "$jq_output"
git annex push --no-content
git annex push --cleanup
fi
- name: Deposit changes
uses: ./.forgejo/actions/deposit-changes