-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (98 loc) · 3.45 KB
/
transkribus-doc-deletion.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Delete Transkribus documents from a collection
on:
issues:
types: [opened, edited]
issue_comment:
types: [created, edited]
jobs:
run:
if: always() && ${{ contains(fromJson(vars.WHITELIST),github.actor) }}
runs-on: ubuntu-latest
outputs:
output1: ${{ steps.ipynb-txt.outputs.out }}
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:doc-deletion')
- uses: stefanbuck/github-issue-parser@v3
if: contains(env.TASKS,'task:doc-deletion')
id: issue-parser
with:
template-path: .github/ISSUE_TEMPLATE/1-doc-deletion.yml
- run: cat ${HOME}/issue-parser-result.json
if: contains(env.TASKS,'task:doc-deletion')
- run: cp ${HOME}/issue-parser-result.json ./issue-parser-result.json
if: contains(env.TASKS,'task:doc-deletion')
- name: Set up Python
if: contains(env.TASKS,'task:doc-deletion')
uses: actions/setup-python@v5
with:
python-version: '3.11'
- uses: yaananth/run-notebook@v2
if: contains(env.TASKS,'task:doc-deletion')
id: ipynb
env:
RUNNER: ${{ toJson(runner) }}
SECRETS: ${{ toJson(secrets) }}
GITHUB: ${{ toJson(github) }}
ISSUE: ./issue-parser-result.json
with:
notebook: "./iiif-to-transkribus/transkribus-doc-deletion.ipynb"
params: "./iiif-to-transkribus/default-params.json"
isReport: False
poll: True
# for easier debugging:
- uses: actions/upload-pages-artifact@v3
if: always() && contains(env.TASKS,'task:doc-deletion')
with:
name: output
path: ${{ RUNNER.temp }}/nb-runner
env:
RUNNER: ${{ toJson(runner) }}
# output for auto reply
- name: Read notebook capture into a github actions output
if: contains(env.TASKS,'task:doc-deletion')
id: ipynb-txt
run: |
{
echo 'out<<DELIM'
cat ./ipynb.txt
echo
echo DELIM
} >> "$GITHUB_OUTPUT"
# adding a reply to the issue thread
add-comment:
needs: run
runs-on: ubuntu-latest
env:
TASKS: ${{ join(github.event.issue.labels.*.name,', ') }}
permissions:
issues: write
steps:
- name: Add comment
if: contains(env.TASKS,'task:doc-deletion')
# run: gh issue comment "$NUMBER" --body-file ./ipynb.txt
run: gh issue comment "$NUMBER" --body "$BODY"
env:
OUTPUT1: ${{needs.run.outputs.output1}}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.issue.number }}
BODY: ${{needs.run.outputs.output1}}
# 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)"