From 7f851c8c3789f745bdf7d07546084be224c714fb Mon Sep 17 00:00:00 2001 From: Francois Kritzinger Date: Thu, 19 Dec 2024 14:10:25 +0200 Subject: ci-github: handle_check_run_rerequest(): get IAT earlier --- mod/mod-ci-github.cxx | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/mod/mod-ci-github.cxx b/mod/mod-ci-github.cxx index 3f685f1..cbd8e70 100644 --- a/mod/mod-ci-github.cxx +++ b/mod/mod-ci-github.cxx @@ -946,6 +946,9 @@ namespace brep bcr.name = cr.check_run.name; ccr.name = conclusion_check_run_name; + const gh_installation_access_token* iat (nullptr); + optional new_iat; + // Load the service data, failing the check runs if the tenant has been // archived. // @@ -974,14 +977,22 @@ namespace brep tenant_id = d->tenant_id; - if (d->archived) // Tenant is archived + // Get a new IAT if the one from the service data has expired. + // + if (system_clock::now () > sd.installation_access.expires_at) { - // Fail (re-create) the check runs. - // - optional iat (get_iat ()); - if (!iat) + if ((new_iat = get_iat ())) + iat = &*new_iat; + else throw server_error (); + } + else + iat = &sd.installation_access; + if (d->archived) // Tenant is archived + { + // Fail the check runs. + // gq_built_result br ( make_built_result ( result_status::error, warning_success, @@ -1040,21 +1051,6 @@ namespace brep } } - // Get a new IAT if the one from the service data has expired. - // - const gh_installation_access_token* iat (nullptr); - optional new_iat; - - if (system_clock::now () > sd.installation_access.expires_at) - { - if ((new_iat = get_iat ())) - iat = &*new_iat; - else - throw server_error (); - } - else - iat = &sd.installation_access; - // Fail if it's the conclusion check run that is being re-requested. // // @@ TMP When user selects re-run all failed checks we receive multiple -- cgit v1.1