0
0
mirror of https://github.com/thegeeklab/wp-s3-action.git synced 2024-11-25 10:20:39 +00:00
wp-s3-action/DOCS.md

120 lines
4.4 KiB
Markdown
Raw Normal View History

2015-10-16 20:09:45 +00:00
Use the S3 sync plugin to synchronize files and folders with an Amazon S3 bucket. The following parameters are used to configure this plugin:
* `access_key` - amazon key
* `secret_key` - amazon secret key
* `bucket` - bucket name
* `region` - bucket region (`us-east-1`, `eu-west-1`, etc)
* `acl` - access to files that are uploaded (`private`, `public-read`, etc)
* `source` - location of folder to sync
* `target` - target folder in your S3 bucket
* `delete` - deletes files in the target not found in the source
2015-11-19 00:39:05 +00:00
* `content_type` - override default mime-types to use this value
* `content_encoding` - override default content encoding header for files
2016-10-19 17:56:28 +00:00
* `cache_control` - override default cache control header for files
2015-11-19 00:39:05 +00:00
* `metadata` - set custom metadata
2015-12-04 19:24:34 +00:00
* `redirects` - targets that should redirect elsewhere
* `cloudfront_distribution_id` - (optional) the cloudfront distribution id to invalidate after syncing
2015-10-16 20:09:45 +00:00
The following is a sample S3 configuration in your .drone.yml file:
```yaml
publish:
s3_sync:
acl: public-read
region: "us-east-1"
bucket: "my-bucket.s3-website-us-east-1.amazonaws.com"
access_key: "970d28f4dd477bc184fbd10b376de753"
secret_key: "9c5785d3ece6a9cdefa42eb99b58986f9095ff1c"
source: folder/to/archive
target: /target/location
delete: true
cloudfront_distribution_id: "9c5785d3ece6a9cdefa4"
```
2016-10-19 17:56:28 +00:00
The `acl`, `content_type`, `cache_control`, and `content_encoding` parameters can be passed as a string value to apply to all files, or as a map to apply to a subset of files.
For example:
```yaml
publish:
s3_sync:
acl:
"public/*": public-read
"private/*": private
content_type:
".svg": image/svg+xml
content_encoding:
".js": gzip
".css": gzip
2016-10-19 17:56:28 +00:00
cache_control: "public, max-age: 31536000"
region: "us-east-1"
bucket: "my-bucket.s3-website-us-east-1.amazonaws.com"
access_key: "970d28f4dd477bc184fbd10b376de753"
secret_key: "9c5785d3ece6a9cdefa42eb99b58986f9095ff1c"
source: folder/to/archive
target: /target/location
delete: true
```
2015-11-19 00:39:05 +00:00
In the case of `acl` the key of the map is a glob. If there are no matches in your settings for a given file, the default is `"private"`.
The `content_type` field the key is an extension including the leading dot `.`. If you want to set a content type for files with no extension, set the key to the empty string `""`. If there are no matches for the `content_type` of any file, one will automatically be determined for you.
2015-11-19 00:39:05 +00:00
In the `content_encoding` field the key is an extension including the leading dot `.`. If you want to set a encoding type for files with no extension, set the key
to th empty string `""`. If there are no matches for the `content_encoding` of a file, no content-encoding header will be added.
2016-10-19 18:59:17 +00:00
In the `cache_control` field the key is an extension including the leading dot `.`. If you want to set cache control for files with no extension, set the key
to the empty string `""`. If there are no matches for the `cache_control` of a file, no cache-control header will be added.
2016-10-19 17:56:28 +00:00
2015-11-19 00:39:05 +00:00
The `metadata` field can be set as either an object where the keys are the metadata headers:
```yaml
publish:
s3_sync:
acl: public-read
region: "us-east-1"
bucket: "my-bucket.s3-website-us-east-1.amazonaws.com"
access_key: "970d28f4dd477bc184fbd10b376de753"
secret_key: "9c5785d3ece6a9cdefa42eb99b58986f9095ff1c"
source: folder/to/archive
target: /target/location
delete: true
metadata:
2016-10-19 17:56:28 +00:00
custom-meta: "abc123"
2015-11-19 00:39:05 +00:00
```
Or you can specify metadata for file patterns by using a glob:
```yaml
publish:
s3_sync:
acl: public-read
region: "us-east-1"
bucket: "my-bucket.s3-website-us-east-1.amazonaws.com"
access_key: "970d28f4dd477bc184fbd10b376de753"
secret_key: "9c5785d3ece6a9cdefa42eb99b58986f9095ff1c"
source: folder/to/archive
target: /target/location
delete: true
metadata:
"*.png":
2016-10-19 17:56:28 +00:00
CustomMeta: "abc123"
2015-11-19 00:39:05 +00:00
```
2015-12-04 19:24:34 +00:00
Additionally, you can specify redirect targets for files that don't exist by using the `redirects` key:
```yaml
publish:
s3_sync:
acl: public-read
region: "us-east-1"
bucket: "my-bucket.s3-website-us-east-1.amazonaws.com"
access_key: "970d28f4dd477bc184fbd10b376de753"
secret_key: "9c5785d3ece6a9cdefa42eb99b58986f9095ff1c"
source: folder/to/archive
target: /target/location
delete: true
redirects:
some/missing/file: /somewhere/that/actually/exists
```