blob: eeacd2ec0e298c8c833f1a23916d2abfe2970c44 (
plain)
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
|
#!/usr/bin/env python3
#
# Builds a list of nightly builds from GitHub releases
#
# Requires the following environment variables:
# SNAPSHOTS_BUCKET
# AWS_ACCESS_KEY_ID
# AWS_SECRET_ACCESS_KEY
import os
import re
import sys
import json
import github
import jinja2
REPO = 'vyos/vyos-nightly-build'
def list_images(repo):
images = []
# GitHub returns releases sorted by date from newest to oldest,
# so we don't need to sort them
releases = repo.get_releases()
for r in releases:
iso = r.assets[0]
sig = r.assets[1]
# Nightly build releases have two assets:
# an ISO and a Minisign signature file
# The signature is always the second asset in the list
image = {}
image["iso_url"] = iso.browser_download_url
image["sig_url"] = sig.browser_download_url
image["title"] = r.title
images.append(image)
return images
def render_image_list(images):
tmpl = jinja2.Template("""
<ul>
{% for i in images %}
<li><a href="{{i.iso_url}}">{{i.title}}</a> (<a href="{{i.sig_url}}">sig</a>)</li>
{% endfor %}
</ul>
""")
return tmpl.render(images=images)
if __name__ == '__main__':
gh_token_string = os.getenv('GH_ACCESS_TOKEN')
gh_auth = github.Auth.Token(gh_token_string)
gh = github.Github(auth=gh_auth)
repo = gh.get_repo(REPO)
images = list_images(repo)
print(render_image_list(images))
|