Skip to content

[Export]: 4946502

[Export]: 4946502 #3

name: Export and validate PAGE XML from Transkribus (by document)
on:
issues:
types: [opened, edited]
issue_comment:
types: [created, edited]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
run:
if: always() && ${{ contains(fromJson(vars.WHITELIST),github.actor) }}
runs-on: ubuntu-latest
outputs:
schematron_is_valid: ${{ steps.schematron-result.outputs.schematron_is_valid }}
schematron_svrl: ${{ steps.schematron-svrl.outputs.schematron_svrl }}
issue_reply_file: ${{ steps.issue-reply.outputs.issue_reply_file }}
env:
TASKS: ${{ join(github.event.issue.labels.*.name,', ') }}
steps:
- run: echo ${{join(github.event.issue.labels.*.name,', ')}}
- run: echo env.TASKS
- uses: actions/checkout@v4
if: contains(env.TASKS,'task:transkribus-export')
- uses: stefanbuck/github-issue-parser@v3
if: contains(env.TASKS,'task:transkribus-export')
id: issue-parser
with:
template-path: .github/ISSUE_TEMPLATE/transkribus-export.yml
- run: cat ${HOME}/issue-parser-result.json
if: contains(env.TASKS,'task:transkribus-export')
- run: cp ${HOME}/issue-parser-result.json ./issue-parser-result.json
if: contains(env.TASKS,'task:transkribus-export')
- name: Set up Python
uses: actions/setup-python@v5
if: contains(env.TASKS,'task:transkribus-export')
with:
python-version: '3.12'
- uses: fzimmermann89/run-notebook@v3
id: ipynb
if: contains(env.TASKS,'task:transkribus-export')
env:
RUNNER: ${{ toJson(runner) }}
SECRETS: ${{ toJson(secrets) }}
GITHUB: ${{ toJson(github) }}
ISSUE: ./issue-parser-result.json
with:
notebook: "./transkribus-export/transkribus-export.ipynb"
params: "./transkribus-export/default-params.json"
isReport: False
poll: True
- run: ls -l
if: contains(env.TASKS,'task:transkribus-export')
# output for auto reply
- name: Read result file
if: contains(env.TASKS,'task:transkribus-export')
id: schematron-result
run: |
{
echo 'schematron_is_valid<<DELIM'
cat ./validation_is_valid.txt
echo
echo DELIM
} >> "$GITHUB_OUTPUT"
# not sure we need this:
- name: Read svrl file
if: contains(env.TASKS,'task:transkribus-export')
id: schematron-svrl
run: |
{
echo 'schematron_svrl<<DELIM'
cat ./validation_output-svrl.xml
echo
echo DELIM
} >> "$GITHUB_OUTPUT"
- name: Read issue reply file
if: contains(env.TASKS,'task:transkribus-export')
id: issue-reply
run: |
{
echo 'issue_reply_file<<DELIM'
cat ./issue-reply.txt
echo
echo DELIM
} >> "$GITHUB_OUTPUT"
- run: |
{
echo "### Workflow variables"
echo "| Variable | Description |Value |"
echo "| ------------------- | ------------------- | ------------------ |"
echo "| schematron_is_valid | Document is valid? | ${{ steps.schematron-result.outputs.schematron_is_valid }} |"
} >> $GITHUB_STEP_SUMMARY
# - run: echo "${{ steps.schematron-result.outputs.schematron_is_valid }}"
# if: contains(env.TASKS,'task:transkribus-export')
- run: ls -l
if: steps.schematron-result.outputs.schematron_is_valid == 'True' && contains(env.TASKS,'task:transkribus-export')
- run: mkdir -p ./data/0-transkribus-PAGE ./data/1-raw-TEI ./data/2-base-TEI
if: steps.schematron-result.outputs.schematron_is_valid == 'True' && contains(env.TASKS,'task:transkribus-export')
- run: tree -L 1
if: steps.schematron-result.outputs.schematron_is_valid == 'True' && contains(env.TASKS,'task:transkribus-export')
# for easier debugging:
- uses: actions/upload-pages-artifact@v3
if: contains(env.TASKS,'task:transkribus-export')
with:
name: output
path: .
env:
RUNNER: ${{ toJson(runner) }}
# adding a reply to the issue thread
add-comment-invalid:
needs: run
runs-on: ubuntu-latest
#outputs:
# issue_reply: ${{ steps.prepare-comment.outputs.issue_reply }}
env:
TASKS: ${{ join(github.event.issue.labels.*.name,', ') }}
ISSUE_MD: ${{ needs.run.outputs.issue_reply_file }}
permissions:
issues: write
steps:
- run: ls -l
- name: Prepare comment (success)
id: prepare-comment-success
if: needs.run.outputs.schematron_is_valid == 'True' && contains(env.TASKS,'task:transkribus-export')
run: |
{
echo 'issue_reply<<DELIM'
echo 'Validation successful: '
echo ${{ needs.run.outputs.schematron_is_valid }}
echo
echo DELIM
} >> "$GITHUB_OUTPUT"
- name: Prepare comment (failure)
id: prepare-comment-failure
if: needs.run.outputs.schematron_is_valid == 'False' && contains(env.TASKS,'task:transkribus-export')
run: |
{
echo 'issue_reply<<DELIM'
echo '# Validation not successful :stop_sign:'
echo "$ISSUE_MD"
echo
echo DELIM
} >> "$GITHUB_OUTPUT"
# go on here with base transformation
- name: Add comment
if: needs.run.outputs.schematron_is_valid == 'False' && contains(env.TASKS,'task:transkribus-export')
# run: gh issue comment "$NUMBER" --body-file ./ipynb.txt
run: gh issue comment "$NUMBER" --body "$BODY"
env:
OUTPUT1: ${{needs.run.outputs.schematron_is_valid}}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.issue.number }}
BODY: ${{ steps.prepare-comment-success.outputs.issue_reply }} ${{ steps.prepare-comment-failure.outputs.issue_reply }}
# also add comment for success case (TBD)
# adding a reply to the issue thread in case of non-authorization
add-comment-unauthorized:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Add comment
if: ${{ ! contains(fromJson(vars.WHITELIST),github.actor)}}
run: gh issue close "$NUMBER" -c "$BODY"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.issue.number }}
BODY: "**Initiator of the action (${{ github.actor }}) is not whitelisted.**\n\n **Aborting.**\n\n\n [Edit `WHITELIST`](https://github.com/pdaengeli/IIIF-to-Transkribus-test/settings/variables/actions/WHITELIST)"
# DONE get xml files
# DONE combine and validate (Schematron)
# DONE problems
# transform to raw TEI
# transform to project TEI model