Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Simple script to upload Python app build to static storage.
- """
- import os
- import subprocess
- import boto3
- KEY = os.environ['S3_BUILD_KEY']
- SECRET = os.environ['S3_BUILD_SECRET']
- BUCKET = os.environ['S3_BUILD_BUCKET']
- output = subprocess.check_output(['git', 'tag'])
- tags = output.decode().split("\n")
- latest = tags[-2]
- print("### working on tag ... {} ####".format(latest))
- # Make the archive file using the system commands
- build_file = "<ProjctName>-{}.tar.gz".format(latest)
- os.system("tar -cvf {} admin".format(build_file))
- print("#### uploading ...######")
- client = boto3.client("s3", config= boto3.session.Config(signature_version='s3v4'),
- aws_access_key_id=KEY,
- region_name="us-east-1",
- aws_secret_access_key=SECRET)
- client.upload_file(build_file, BUCKET, build_file)
- print("####### removing archive #######")
- os.system("rm {}".format(build_file))
- print("####### deplying in dev #########")
- os.system("ansible-playbook deploy.yml --extra-vars 'tag={}'".format(latest))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement