Skip to content

Commit

Permalink
add enpoint param
Browse files Browse the repository at this point in the history
  • Loading branch information
tvrcgo committed Jan 12, 2021
1 parent 06e0971 commit dbc0fe9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

- `key-id`: OSS AccessKeyId
- `key-secret`: OSS AccessKeySecret
- `region`: 区域,如 `oss-cn-shenzhen`
- `bucket`:
- `region`: 区域,如 `oss-cn-shenzhen`,和 endpoint 二选一
- `endpoint`: 优先级高于 region,可填写内网节点、加速节点,和 region 二选一
- `bucket`: Bucket 名称
- `asset-path`: 本地资源路径
- `target-path`: OSS 对象存储路径

Expand Down
4 changes: 3 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ branding:
color: 'yellow'
inputs:
region:
required: true
required: false
endpoint:
required: false
key-id:
required: true
key-secret:
Expand Down
2 changes: 1 addition & 1 deletion lib/index.js

Large diffs are not rendered by default.

15 changes: 12 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,21 @@ const fg = require('fast-glob');

(async () => {
try {
const oss = new OSS({
region: core.getInput('region'),
const opts = {
accessKeyId: core.getInput('key-id'),
accessKeySecret: core.getInput('key-secret'),
bucket: core.getInput('bucket')
})
}

;['region', 'endpoint']
.filter(name => core.getInput(name))
.forEach(name => {
Object.assign(opts, {
[name]: core.getInput(name)
})
})

const oss = new OSS(opts)

const assetPath = core.getInput('asset-path', { required: true }).replace(/\/+$/g, '')
const targetPath = core.getInput('target-path', { required: true }).replace(/\/+$/g, '')
Expand Down

0 comments on commit dbc0fe9

Please sign in to comment.