Skip to content

Commit

Permalink
feat: allow use template for s3 bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatur authored and caarlos0 committed Jan 22, 2019
1 parent db7686f commit 0aa80ec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions internal/pipe/s3/s3.go
Expand Up @@ -71,6 +71,12 @@ func upload(ctx *context.Context, conf config.S3) error {
svc := s3.New(sess, &aws.Config{
Region: aws.String(conf.Region),
})

bucket, err := tmpl.New(ctx).Apply(conf.Bucket)
if err != nil {
return err
}

folder, err := tmpl.New(ctx).Apply(conf.Folder)
if err != nil {
return err
Expand All @@ -93,12 +99,12 @@ func upload(ctx *context.Context, conf config.S3) error {
return err
}
log.WithFields(log.Fields{
"bucket": conf.Bucket,
"bucket": bucket,
"folder": folder,
"artifact": artifact.Name,
}).Info("uploading")
_, err = svc.PutObjectWithContext(ctx, &s3.PutObjectInput{
Bucket: aws.String(conf.Bucket),
Bucket: aws.String(bucket),
Key: aws.String(filepath.Join(folder, artifact.Name)),
Body: f,
ACL: aws.String(conf.ACL),
Expand Down
1 change: 1 addition & 0 deletions www/content/s3.md
Expand Up @@ -22,6 +22,7 @@ s3:
# You can have multiple s3 configs
-
# Bucket name (without the s3:// prefix)
# You can use `{{ .Env.BUCKET_ID }}`
# Default is empty.
bucket: my-bucket
# AWS Region to use.
Expand Down

0 comments on commit 0aa80ec

Please sign in to comment.