Skip to content
This repository was archived by the owner on Oct 4, 2024. It is now read-only.

Commit f0d8000

Browse files
authored
Merge pull request #41 from eamonnfaherty/feature/branch-names-in-s3
adding branch name to the object path
2 parents a405f42 + 5d33049 commit f0d8000

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea

functions/source/GitPullS3/lambda_function.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ def zip_repo(repo_path, repo_name):
111111
return '/tmp/'+repo_name.replace('/', '_')+'.zip'
112112

113113

114-
def push_s3(filename, repo_name, outputbucket):
115-
s3key = '%s/%s' % (repo_name, filename.replace('/tmp/', ''))
114+
def push_s3(filename, repo_name, branch_name, outputbucket):
115+
s3key = '%s/%s/%s' % (repo_name, branch_name, filename.replace('/tmp/', ''))
116116
logger.info('pushing zip to s3://%s/%s' % (outputbucket, s3key))
117117
data = open(filename, 'rb')
118118
s3.put_object(Bucket=outputbucket, Body=data, Key=s3key)
@@ -226,7 +226,7 @@ def lambda_handler(event, context):
226226
repo = create_repo(repo_path, remote_url, creds)
227227
pull_repo(repo, branch_name, remote_url, creds)
228228
zipfile = zip_repo(repo_path, repo_name)
229-
push_s3(zipfile, repo_name, outputbucket)
229+
push_s3(zipfile, repo_name, branch_name, outputbucket)
230230
if cleanup:
231231
logger.info('Cleanup Lambda container...')
232232
shutil.rmtree(repo_path)

0 commit comments

Comments
 (0)