Skip to content

Commit

Permalink
Development (#3)
Browse files Browse the repository at this point in the history
* fix validate pipeline

* fix typos in readme and improve example

* run validate pipeline on all branches

* checkout projetct in validate flow

* install deps

* run all test workflows on all branches

* simplify aws action

* simplify linode action

* restructure project and bump vulnerable node fetch version

Signed-off-by: Nico Braun <[email protected]>
  • Loading branch information
bluebrown authored Mar 18, 2022
1 parent 7ecaeb9 commit 6dca00b
Show file tree
Hide file tree
Showing 22 changed files with 441 additions and 213 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
tab_width = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
12 changes: 3 additions & 9 deletions .github/workflows/aws.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
on:
push:
branches:
- main
workflow_dispatch:

jobs:
use_s3cmd:
runs-on: ubuntu-latest

name: Use S3cmd for AWS
steps:
- name: Set up S3cmd cli tool
uses: s3-actions/s3cmd@main
with:
provider: aws
region: 'eu-central-1'
region: eu-central-1
access_key: ${{ secrets.S3_ACCESS_KEY_AWS }}
secret_key: ${{ secrets.S3_SECRET_KEY_AWS }}

Expand All @@ -24,10 +22,6 @@ jobs:
s3cmd mb s3://$buck
echo 'foo' >> example/bar
s3cmd put example/bar s3://$buck
mkdir -p example/baz/bar
echo 'fizz' >> example/baz/bar/faz
sleep 10
s3cmd sync --recursive --acl-public example s3://$buck
sleep 10
s3cmd rm -r --force s3://$buck
sleep 10
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/digitalocean.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
on:
push:
branches:
- main
workflow_dispatch:

jobs:
use_s3cmd:
runs-on: ubuntu-latest

name: Use S3cmd for digitalocean
steps:
- name: Set up S3cmd cli tool
uses: s3-actions/s3cmd@main
with:
provider: digitalocean
region: 'NYC3'
region: NYC3
access_key: ${{ secrets.SPACES_ACCESS_KEY_ID }}
secret_key: ${{ secrets.SPACES_SECRET_ACCESS_KEY }}

Expand Down
12 changes: 3 additions & 9 deletions .github/workflows/linode.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
on:
push:
branches:
- main
workflow_dispatch:

jobs:
use_s3cmd:
runs-on: ubuntu-latest

name: Use S3cmd for Linode
steps:
- name: Set up S3cmd cli tool
uses: s3-actions/s3cmd@main
with:
region: 'eu-central-1'
region: eu-central-1
access_key: ${{ secrets.S3_ACCESS_KEY_LINODE }}
secret_key: ${{ secrets.S3_SECRET_KEY_LINODE }}

Expand All @@ -23,10 +21,6 @@ jobs:
s3cmd mb s3://$buck
echo 'foo' >> example/bar
s3cmd put example/bar s3://$buck
mkdir -p example/baz/bar
echo 'fizz' >> example/baz/bar/faz
sleep 10
s3cmd sync --recursive --acl-public example s3://$buck
sleep 10
s3cmd rm -r --force s3://$buck
sleep 10
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
on:
push:
branches:
- main
on: push

jobs:
use_s3cmd:
runs-on: ubuntu-latest

name: Validate Project
steps:
- name: Build dist
- uses: actions/checkout@v2
- run: |
npm i
mv dist/index.js old
npm run build
if cmp --silent -- old dist/index.js; then
exit 0
else
exit 1
fi
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules
.vscode
.s3cfg
/assets/test-results/*
!/assets/test-results/.gitkeep
27 changes: 16 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
# S3cmd

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

Currently AWS and Linode are supported as provider but it could be used with other providers too when using additional flags.
## Supported Providers

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

- AWS
- Linode
- DigitalOcean

## Inputs

### `provider`

**Not Required** The s3 provider to use. Defaults to Linode. Currently AWS and Linode possible.
**Not Required** The s3 provider to use. Defaults to Linode. AWS, Linode, DigitalOcean are supported.

### `secret_key`

Expand All @@ -20,7 +26,7 @@ Currently AWS and Linode are supported as provider but it could be used with oth

### `region`

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

## Example usage

Expand All @@ -35,17 +41,17 @@ Currently AWS and Linode are supported as provider but it could be used with oth

- name: Interact with object storage
run: |
s3cmd sync --recursive --acl-public dist s3://awesome.blog
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 s://my-bucket
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.
Expand All @@ -54,11 +60,10 @@ For linode object storage this wont work though. The region must always be set t
s3cmd mb --host ap-south-1.linodeobjects.com s3://my-bucket
```


## Development

Copy hooks into git folder
Copy the hooks into the git folder:

```shell
cp assets/hooks/* .git/hooks/
```
cp hooks/* .git/hooks/
```
28 changes: 15 additions & 13 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
name: 'Use S3cmd'
description: 'Use S3cmd cli to interact with s3 object storage.'
name: "Use S3cmd"
description: "Use S3cmd cli to interact with s3 object storage"
branding:
icon: 'award'
color: 'green'
icon: "award"
color: "green"
inputs:
provider:
description: 'config provider to make it easier to use the cli as action'
default: 'linode'
description: "config provider to make it easier to use the cli as action"
default: "linode"
required: false
region:
description: 's3 region'
access_key:
description: 's3 access key'
description: "s3 region (default region depends on the provider)"
required: false
access_key:
description: "s3 access key"
required: true
secret_key:
description: 's3 secret key'
secret_key:
description: "s3 secret key"
required: true
runs:
using: 'node12'
main: 'dist/index.js'
using: "node12"
main: "dist/index.js"
File renamed without changes.
14 changes: 14 additions & 0 deletions assets/test-app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="./style.css">
</head>
<body>
<h1>Test</h1>
<script src="./main.js"></script>
</body>
</html>
1 change: 1 addition & 0 deletions assets/test-app/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('foo')
8 changes: 8 additions & 0 deletions assets/test-app/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
html, body {
padding: 0;
margin: 0;
}
body {
background: pink;
min-height: 100vh;
}
82 changes: 0 additions & 82 deletions assets/test-result

This file was deleted.

Empty file added assets/test-results/.gitkeep
Empty file.
Loading

0 comments on commit 6dca00b

Please sign in to comment.