Skip to content

Commit

Permalink
feat: 新增 download-flag 參數
Browse files Browse the repository at this point in the history
可以用在下載字型檔案時
注入到 wget 指令中
控制輸出或是其他需要
預設為 -nv
  • Loading branch information
hms5232 committed Jul 23, 2022
1 parent 6d8208e commit 842c15b
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,37 @@ steps:
```
※由於 Github action 的問題,目前還不支援輸入布林值,故請使用字串!詳見:[actions/runner#1483](https://github.com/actions/runner/issues/1483)
### 客製下載旗標(flag)
下載字型的工具是 wget,如果有 debug 或其他需求,可以使用 `download-flag` 參數指示 wget 輸出或行為。

預設情況:
```yaml
steps:
- uses: hms5232/install-CNS11643-fonts-action@v1 # 依照需求設定版本號或是 SHA
with:
download-flag: '-nv' # 本 action 預設值,代表 no verbose
```

通常輸出(正常使用 wget 沒特別指定時):
```yaml
steps:
- uses: hms5232/install-CNS11643-fonts-action@v1 # 依照需求設定版本號或是 SHA
with:
download-flag: '-v' # wget 預設值,代表 verbose
```

debug 輸出:
```yaml
steps:
- uses: hms5232/install-CNS11643-fonts-action@v1 # 依照需求設定版本號或是 SHA
with:
download-flag: '-d' # 代表 debug
```

其他參數請見 wget 文件。

由於此參數為直接注入輸入指令中,請小心使用!

### 進階設定建議
細節請見各項設定的後方說明:
```yaml
Expand Down
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@ inputs:
description: 'Install 正宋體 or not'
required: false
default: 'true'
download-flag:
description: 'Add flag(s) when use wget'
required: false
default: '-nv'
runs:
using: "composite"
steps:
- run: ${{ github.action_path }}/init.sh
shell: bash
- run: |
echo "::group::download and unzip"
${{ github.action_path }}/download.sh || echo "Download completed"
${{ github.action_path }}/download.sh -f "${{ inputs.download-flag }}" || echo "Download completed"
echo "::endgroup::"
shell: bash
- run: ${{ github.action_path }}/copy.sh kai
Expand Down
11 changes: 10 additions & 1 deletion download.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
#!/bin/bash

wget -O cns11643.zip http://www.cns11643.gov.tw/AIDB/Open_Data.zip

while getopts 'f:' flag; do
case "${flag}" in
f) flags="${OPTARG}" ;;
*) print_usage
exit 1 ;;
esac
done

wget -O cns11643.zip ${flags} http://www.cns11643.gov.tw/AIDB/Open_Data.zip

# let's hash it~
# but we don't have offical sha1sum file Orz
Expand Down

0 comments on commit 842c15b

Please sign in to comment.