-
Notifications
You must be signed in to change notification settings - Fork 6
/
deployment.py
59 lines (45 loc) · 1.72 KB
/
deployment.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
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
'''
To run
'''
import argparse
import os
import sys
import json
MEMBERS = ['will', 'greg', 'tyler', 'kim', 'andy', 'andy2']
def main():
parser = argparse.ArgumentParser(description='''
Set branch for personal vertex deployments, branch defaults to current checkout branch.
For more info checkout readme.
''')
parser.add_argument('deployment',
help=f'Deployment to update. ({MEMBERS})')
parser.add_argument('--branch', '-b',
help='branch to set codepipline to pull from')
args = parser.parse_args()
member, branch = args.deployment, args.branch
if branch is None:
branch = os.popen('git rev-parse --abbrev-ref HEAD').read().strip()
if not is_valid_member(member):
print(f'"{member}" does not have a deployment.')
return
deployment = f'SearchUI-{member}'
pipeline_file = 'pipeline.json'
os.system(f'aws codepipeline get-pipeline --name {deployment} > {pipeline_file}')
with open(pipeline_file) as f:
pipeline = json.loads(f.read())
print(f'Updating pipeline "{deployment}" to build from "{branch}"')
pipeline['pipeline']['stages'][0]['actions'][0]['configuration']['BranchName'] = branch
pipeline = {
'pipeline': pipeline['pipeline']
}
with open(pipeline_file, 'w') as f:
json.dump(pipeline, f)
os.system(f'aws codepipeline update-pipeline --cli-input-json file://{pipeline_file} > /dev/null')
print('Done.')
print('\nStarting pipeline...')
os.system(f'aws codepipeline start-pipeline-execution --name {deployment}')
os.system(f'rm {pipeline_file}')
def is_valid_member(member):
return member in MEMBERS
if __name__ == "__main__":
main()