This repository has been archived by the owner on Mar 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 70
/
orb.yml
144 lines (137 loc) · 4.92 KB
/
orb.yml
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
version: 2.1
description: |
A set of tools for working with Amazon S3. Requirements: bash
Source: https://github.com/circleci-public/circleci-orbs
examples:
basic_commands:
description: "Examples uses aws s3 commands"
usage:
version: 2.1
orbs:
aws-s3: circleci/aws-s3@1.0.0
jobs:
build:
docker:
- image: circleci/python:2.7
steps:
- checkout
- run: mkdir bucket && echo "lorum ipsum" > bucket/build_asset.txt
- aws-s3/sync:
from: bucket
to: "s3://my-s3-bucket-name/prefix"
arguments: |
--acl public-read \
--cache-control "max-age=86400"
overwrite: true
- aws-s3/copy:
from: bucket/build_asset.txt
to: "s3://my-s3-bucket-name"
arguments: --dryrun
override_credentials:
description: "Examples uses aws s3 commands with credentials overriding"
usage:
version: 2.1
orbs:
aws-s3: circleci/aws-s3@1.0.0
jobs:
build:
docker:
- image: circleci/python:2.7
steps:
- checkout
- run: mkdir bucket && echo "lorum ipsum" > bucket/build_asset.txt
- aws-s3/sync:
from: bucket
to: "s3://my-s3-bucket-name/prefix"
aws-access-key-id: AWS_ACCESS_KEY_ID_BLUE
aws-secret-access-key: AWS_SECRET_ACCESS_KEY_BLUE
aws-region: AWS_REGION_BLUE
arguments: |
--acl public-read \
--cache-control "max-age=86400"
overwrite: true
- aws-s3/copy:
from: bucket/build_asset.txt
to: "s3://my-s3-bucket-name"
arguments: --dryrun
orbs:
aws-cli: circleci/aws-cli@0.1.13
commands:
sync:
description: "Syncs directories and S3 prefixes. https://docs.aws.amazon.com/cli/latest/reference/s3/sync.html"
parameters:
from:
type: string
description: A local *directory* path to sync with S3
to:
type: string
description: A URI to an S3 bucket, i.e. 's3://the-name-my-bucket'
arguments:
type: string
default: ""
description: >
Optional additional arguments to pass to the `aws sync` command
(e.g., `--acl public-read`). Note: if passing a multi-line value
to this parameter, include `\` characters after each line, so the
Bash shell can correctly interpret the entire command.
overwrite:
default: false
type: boolean
aws-access-key-id:
type: env_var_name
description: aws access key id override
default: AWS_ACCESS_KEY_ID
aws-secret-access-key:
type: env_var_name
description: aws secret access key override
default: AWS_SECRET_ACCESS_KEY
aws-region:
type: env_var_name
description: aws region override
default: AWS_REGION
steps:
- aws-cli/install
- aws-cli/configure:
aws-access-key-id: << parameters.aws-access-key-id >>
aws-secret-access-key: << parameters.aws-secret-access-key >>
aws-region: << parameters.aws-region >>
- deploy:
name: Deploy to S3
command: |
aws s3 sync \
<<parameters.from>> <<parameters.to>><<#parameters.overwrite>> --delete<</parameters.overwrite>><<#parameters.arguments>> \
<<parameters.arguments>><</parameters.arguments>>
copy:
description: "Copies a local file or S3 object to another location locally or in S3. https://docs.aws.amazon.com/cli/latest/reference/s3/cp.html"
parameters:
from:
type: string
description: A local file or source s3 object
to:
type: string
description: A local target or s3 destination
arguments:
description: If you wish to pass any additional arguments to the aws copy command (i.e. -sse)
default: ''
type: string
aws-access-key-id:
type: env_var_name
description: aws access key id override
default: AWS_ACCESS_KEY_ID
aws-secret-access-key:
type: env_var_name
description: aws secret access key override
default: AWS_SECRET_ACCESS_KEY
aws-region:
type: env_var_name
description: aws region override
default: AWS_REGION
steps:
- aws-cli/install
- aws-cli/configure:
aws-access-key-id: << parameters.aws-access-key-id >>
aws-secret-access-key: << parameters.aws-secret-access-key >>
aws-region: << parameters.aws-region >>
- run:
name: S3 Copy << parameters.from >> -> << parameters.to >>
command: "aws s3 cp << parameters.from >> << parameters.to >><<# parameters.arguments >> << parameters.arguments >><</ parameters.arguments >>"