Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
region: us-east-1
access_key: supersecret
secret_key: supersecret
icecream_flavor: vanilla

- name: check that s3cmd works
run: s3cmd --dump-config
93 changes: 56 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,39 @@

This action is a simple wrapper for [S3cmd](https://github.com/s3tools/s3cmd).

```yml
- name: Set up S3cmd cli tool
uses: s3-actions/s3cmd@v1.10.1
with:
provider: aws # default is linode
region: 'eu-central-1'
access_key: ${{ secrets.S3_ACCESS_KEY }}
secret_key: ${{ secrets.S3_SECRET_KEY }}

- name: Interact with object storage
run: |
s3cmd sync --recursive --acl-public dist s3://awesome.blog/
s3cmd put dist/style.css --mime-type 'text/css' --acl-public s3://awesome.blog/style.css
s3cmd info s3://awesome.blog
```

> [!NOTE]
> The region only matters when creating a new bucket with `mb`. In that
> case a different region apart from the default region can be provided
> ad hoc.
>
> s3cmd mb --region ap-south-1 s3://my-bucket
>
> For linode object storage this wont work though. The region must always
> be set to US. If you want to change the region on the fly you can still
> do ith with the below command.
>
> s3cmd mb --host ap-south-1.linodeobjects.com s3://my-bucket

## Supported Providers

Currently the below providers are supported, but it could be used with
other providers too when using additional flags.
Currently the below providers are supported, but it could be used with other
providers too when using additional flags.

- AWS
- DigitalOcean
Expand All @@ -21,65 +50,55 @@ other providers too when using additional flags.

## Inputs

### `provider`
### Well Known Inputs

#### `provider`

**Not Required** The s3 provider to use. Defaults to `linode`.

Supported values: `aws`, `digitalocean`, `linode`, `scaleway`,
Supported values: `passthrough`, `aws`, `digitalocean`, `linode`, `scaleway`,
`cloudflare`, `vultr`, `clevercloud`, `hcloud`, `synologyc2`, `wasabi`,
`yandex`.

### `secret_key`
#### `secret_key`

**Required** The buckets secret key.

### `access_key`
#### `access_key`

**Required** The buckets access key.

### `region`
#### `region`

**Not Required** The default region to use. The default depends on the provider.

### `account_id`
#### `account_id`

**Not Required** Cloudflare account ID. Only required when using
Cloudflare R2.

## Example usage
### Arbitrary Inputs

```yml
It is possible to specify aribtrary inputs. These are forwared to the
provider and eventually the config file. There is even a passthrough
provider that simply forwards all inputs to the s3cmd config file. Below
is an example using the passthrough provider, but extra inputs work for
all providers. Some of the well known inputs are removed before
forwarding.

```yaml
- name: Set up S3cmd cli tool
uses: s3-actions/s3cmd@v1.10.1
uses: s3-actions/s3cmd@latest
with:
provider: aws # default is linode
region: 'eu-central-1'
# these are stripped
provider: passthrough
access_key: ${{ secrets.S3_ACCESS_KEY }}
secret_key: ${{ secrets.S3_SECRET_KEY }}

- name: Interact with object storage
run: |
s3cmd sync --recursive --acl-public dist s3://awesome.blog/
s3cmd put dist/style.css --mime-type 'text/css' --acl-public s3://awesome.blog/style.css
s3cmd info s3://awesome.blog
```

### Note

The region only matters when creating a new bucket with `mb`. In that
case a different region apart from the default region can be provided ad
hoc.

```console
s3cmd mb --region ap-south-1 s3://my-bucket
```

For linode object storage this wont work though. The region must always
be set to US. If you want to change the region on the fly you can still
do ith with the below command.

```console
s3cmd mb --host ap-south-1.linodeobjects.com s3://my-bucket
# these are passed through
bucket_host: 'my-bucket.s3.eu-central-1.amazonaws.com'
bucket_host_style: 'path'
bucket_location: 'eu-central-1'
bucket_region: 'eu-central-1'
```

## Development
Expand Down
10 changes: 6 additions & 4 deletions action.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ const { tests } = require("./src/providers");
const { RunOptions, RunTarget } = require("github-action-ts-run-api");

(async () => {
for (const [provider, { giveInputs, wantLines }] of Object.entries(tests)) {
console.log(`\n---\nTesting provider: ${provider}`);
for (const { name, giveInputs, wantLines } of tests) {
const tag = name || giveInputs.provider || "unknown";

console.log(`\n---\nTesting provider: ${tag}`);

const target = RunTarget.mainJs("action.yml");
const options = RunOptions.create()
.setFakeFsOptions({ rmFakedTempDirAfterRun: false })
.setInputs({ ...giveInputs, provider });
.setInputs(giveInputs);

const res = await target.run(options);
try {
Expand All @@ -21,7 +23,7 @@ const { RunOptions, RunTarget } = require("github-action-ts-run-api");
const b = readFileSync(join(res.tempDirPath, "s3cmd.conf"));
const data = b.toString();
for (const line of wantLines) {
assert.ok(data.includes(line), `${provider}: missing line: ${line}`);
assert.ok(data.includes(line), `${tag}: missing line: ${line}`);
}
} finally {
res.cleanUpFakedDirs();
Expand Down
Loading
Loading