Get CI archive url

This commit is contained in:
tarsin committed 2023-07-05 09:22:42 +08:00
1 parent 4b562f98f0
commit e97e539f92
2 files changed
+9 -9

No files matched your search

@@ -104,15 +104,15 @@ fun AboutScreen() {
val branchUrl = "$API_URL/branches/$branch"
val commitSha = ehRequest(branchUrl).execute {
JSONObject(body.string()).getJSONObject("commit").getString("sha")
}.take(7)
if (commitSha != curSha) launchSnackBar(commitSha)
val workflowUrl = ehRequest("$API_URL/actions/workflows").execute {
val r = JSONObject(body.string()).getJSONArray("workflows").iter<JSONObject>().find {
it.getString("name") == "CI"
}
if (commitSha.take(7) != curSha) launchSnackBar(commitSha)
val archiveUrl = ehRequest("$API_URL/actions/artifacts").execute {
JSONObject(body.string()).getJSONArray("artifacts").iter<JSONObject>().find {
val wf = it.getJSONObject("workflow_run")
it.getString("name").startsWith("arm64-v8a") && wf.getString("head_sha") == commitSha
}
requireNotNull(r) { "No CI workflow found!!!" }
}.getString("url")
launchSnackBar(workflowUrl)
}?.getString("archive_download_url")
launchSnackBar(archiveUrl ?: "CI is still running, please wait")
} else {
val curVersion = BuildConfig.VERSION_NAME
val releaseUrl = "$API_URL/releases"
@@ -8,6 +8,6 @@ fun <T> JSONArray.iter() = object : Iterable<T> {
override fun hasNext() = index != length()
@Suppress("UNCHECKED_CAST")
override fun next() = get(index) as T
override fun next() = get(index++) as T
}
}