-
Notifications
You must be signed in to change notification settings - Fork 13
/
create-child-ci.py
executable file
·30 lines (25 loc) · 1.06 KB
/
create-child-ci.py
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
#!/usr/bin/python
import urllib.request, json, os, shutil
from jinja2 import Template
releases = "https://alpinelinux.org/releases.json"
template = "child.tpl.yml"
pipeline = "out/child.yml"
with urllib.request.urlopen(releases) as url:
data = json.load(url)
with open(template) as f:
os.makedirs('out', exist_ok=True)
Template(f.read(), trim_blocks=True, lstrip_blocks=True).stream(
data=data['release_branches'][0:5]).dump(pipeline)
f.close()
for branch in data['release_branches'][0:5]:
tag = branch['rel_branch'].lstrip('v')
release = branch['rel_branch']
directory = ('out/{}').format(release)
outfile = os.path.join(directory, 'Dockerfile')
os.makedirs(directory, exist_ok=True)
with open('Dockerfile.in') as f:
Template(f.read(), trim_blocks=True, lstrip_blocks=True).stream(
tag=tag, release=release).dump(outfile)
f.close()
shutil.copyfile('entrypoint.sh', ('out/{}/entrypoint.sh').format(release))
shutil.copymode('entrypoint.sh', ('out/{}/entrypoint.sh').format(release))