-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Maintain and upload artifacts index (#2839)
* Maintain and upload artifacts index Make the artifacts browsable by maintaining a list of builds. This keeps it up-to-date even when deleting images from the object storage, and minimizes queries to the object storage. * Add favicon * Apply suggestions from code review Co-authored-by: Joakim Sørensen <joasoe@gmail.com> * Move index update outside of the build Matrix * Add error handling and styling * Exclude index files * Add cache flush * Use separate prefix for indexes This allows to filter by prefix when generating the main index. Since the list-objects-v2 is limited to 1000 entries, this will be a bottle neck soon. Separating indexes allows to support up to 1000 nightly builds. * Add missing backslash * Use cp and fix index format * Sync index.html as well * Move OS artifacts index file to root directory This is not really GitHub related, so it shouldn't live in there. * Adjust URL for dev builds --------- Co-authored-by: Joakim Sørensen <joasoe@gmail.com>
- Loading branch information
Showing
3 changed files
with
118 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Home Assistant OS - development builds</title> | ||
<link rel="shortcut icon" href="https://brands.home-assistant.io/homeassistant/icon.png"> | ||
<style> | ||
body { | ||
font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif; | ||
} | ||
|
||
.error { | ||
color: maroon; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<h1>Home Assistant OS - development builds</h1> | ||
<select id="os-builds"></select> | ||
<div id="os-builds-list"></div> | ||
<script> | ||
const buildSelect = document.getElementById('os-builds'); | ||
const osBuildsList = document.getElementById('os-builds-list'); | ||
|
||
const fillVersions = async () => { | ||
try { | ||
const response = await fetch('/index.json'); | ||
if (!response.ok) { | ||
const p = document.createElement('p'); | ||
p.className = "error"; | ||
p.textContent = "Could not load version index file."; | ||
osBuildsList.appendChild(p); | ||
return; | ||
} | ||
const items = await response.json(); | ||
items.reverse(); | ||
|
||
items.forEach(buildVersion => { | ||
buildSelect.appendChild(new Option(buildVersion, buildVersion)); | ||
}); | ||
|
||
buildSelect.dispatchEvent(new Event('change')); | ||
} catch (error) { | ||
console.error('Error fetching data:', error); | ||
} | ||
} | ||
|
||
buildSelect.addEventListener('change', async function() { | ||
osBuildsList.innerHTML = ''; | ||
|
||
const buildVersion = this.value; | ||
|
||
try { | ||
const response = await fetch(`/indexes/${buildVersion}.json`); | ||
if (!response.ok) { | ||
const p = document.createElement('p'); | ||
p.className = "error"; | ||
p.textContent = `Could not load index file for version ${buildVersion}.`; | ||
osBuildsList.appendChild(p); | ||
return; | ||
} | ||
const images = await response.json(); | ||
|
||
const ul = document.createElement('ul'); | ||
images.forEach(image => { | ||
const li = document.createElement('li'); | ||
const a = document.createElement('a'); | ||
a.href =`/${buildVersion}/${image}`; | ||
a.textContent = image; | ||
li.appendChild(a); | ||
ul.appendChild(li); | ||
}); | ||
|
||
osBuildsList.appendChild(ul); | ||
} catch (error) { | ||
console.error('Error fetching images:', error); | ||
} | ||
}); | ||
|
||
fillVersions(); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters