Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. """
  2. Simple script to upload Python app build to static storage.
  3. """
  4. import os
  5. import subprocess
  6. import boto3
  7.  
  8. KEY = os.environ['S3_BUILD_KEY']
  9. SECRET = os.environ['S3_BUILD_SECRET']
  10. BUCKET = os.environ['S3_BUILD_BUCKET']
  11.  
  12. output = subprocess.check_output(['git', 'tag'])
  13. tags = output.decode().split("\n")
  14. latest = tags[-2]
  15. print("### working on tag ... {} ####".format(latest))
  16. # Make the archive file using the system commands
  17. build_file = "<ProjctName>-{}.tar.gz".format(latest)
  18. os.system("tar -cvf {} admin".format(build_file))
  19. print("#### uploading ...######")
  20. client = boto3.client("s3", config= boto3.session.Config(signature_version='s3v4'),
  21. aws_access_key_id=KEY,
  22. region_name="us-east-1",
  23. aws_secret_access_key=SECRET)
  24. client.upload_file(build_file, BUCKET, build_file)
  25. print("####### removing archive #######")
  26. os.system("rm {}".format(build_file))
  27. print("####### deplying in dev #########")
  28. os.system("ansible-playbook deploy.yml --extra-vars 'tag={}'".format(latest))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement