Skip to content

Commit

Permalink
Fix webhook processing
Browse files Browse the repository at this point in the history
  • Loading branch information
cmil committed Feb 9, 2024
1 parent 2e6eb07 commit 44ac7b1
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions jobs/process-webhook-delivery.xq
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ declare function local:make-url ($template, $path) {
return $url
};

declare function local:make-target ($path, $corpusname) {
$config:corpora-root || '/' || $corpusname || '/' || (
if ($path = "corpus.xml")
then $path
else replace(
replace($path, '^' || $config:corpus-repo-prefix || '/', ''),
"\.xml$",
"/tei.xml"
)
)
};

declare function local:get-repo-contents ($url-template) {
let $url := local:make-url($url-template, $config:corpus-repo-prefix)
let $response := local:gh-request("get", $url)
Expand All @@ -104,7 +116,7 @@ declare function local:process-delivery () {
let $delivery := collection($config:webhook-root)
/delivery[@id = $local:delivery and not(@processed)]
let $repo := $delivery/@repo/string()
let $corpus := collection($config:data-root)//tei:teiCorpus[
let $corpus := collection($config:corpora-root)//tei:teiCorpus[
tei:teiHeader//tei:publicationStmt/tei:idno[@type="repo" and . = $repo]
]

Expand All @@ -127,9 +139,9 @@ declare function local:process-delivery () {
let $source := if ($path = "corpus.xml")
then local:make-url($contents-url, $path)
else $contents?*[?type = "file" and ?path = $path]?git_url
let $target := $config:data-root || '/' || $corpusname || '/'
|| replace($path, '^' || $config:corpus-repo-prefix || '/', '')
let $target := local:make-target($path, $corpusname)
let $action := $file/@action
let $log := util:log-system-out("Action: "||$action||" Target: "||$target||" Source: "||$source)

let $result := if ($action = "remove") then
local:remove($target)
Expand Down

0 comments on commit 44ac7b1

Please sign in to comment.