From 1c23744cd588b55027c8bd5c4c6cfbcf6f666dd3 Mon Sep 17 00:00:00 2001 From: Yikun Jiang Date: Fri, 27 Mar 2020 17:18:11 +0800 Subject: [PATCH] Add static list support (#23) Closes: #24 --- .github/workflows/verify-on-ubuntu-user.yml | 2 +- README.md | 1 + README_CN.md | 1 + action.yml | 4 ++++ entrypoint.sh | 7 ++++++- 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/verify-on-ubuntu-user.yml b/.github/workflows/verify-on-ubuntu-user.yml index 31feec6e..34aa3b4e 100644 --- a/.github/workflows/verify-on-ubuntu-user.yml +++ b/.github/workflows/verify-on-ubuntu-user.yml @@ -14,4 +14,4 @@ jobs: dst: gitee/yikunkero dst_key: ${{ secrets.GITEE_PRIVATE_KEY }} dst_token: ${{ secrets.GITEE_TOKEN }} - white_list: 'hub-mirror-action' \ No newline at end of file + static_list: 'hub-mirror-action,hashes,simple-spring' diff --git a/README.md b/README.md index 451ad101..a227301c 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ You can see more real workflows in [here](https://github.com/Yikun/hub-mirror-ac - `cache_path` (optional) let code clone in specific path, can be used with actions/cache to speed up mirror. - `black_list` (optional) the black list, such as “repo1,repo2,repo3”. - `white_list` (optional) the white list, such as “repo1,repo2,repo3”. +- `static_list` (optional) Only mirror repos in the static list, but don't get list from repo api dynamically (the white/black list is still available). like 'repo1,repo2,repo3' ## Scenarios diff --git a/README_CN.md b/README_CN.md index f256d4af..d5a000b6 100644 --- a/README_CN.md +++ b/README_CN.md @@ -31,6 +31,7 @@ steps: - `cache_path` (optional) 将代码缓存在指定目录,用于与actions/cache配合以加速镜像过程。 - `black_list` (optional) 配置后,黑名单中的repos将不会被同步,如“repo1,repo2,repo3”。 - `white_list` (optional) 配置后,仅同步白名单中的repos,如“repo1,repo2,repo3”。 +- `static_list` (optional) 配置后,仅同步静态列表,不会再动态获取需同步列表(黑白名单机制依旧生效),如“repo1,repo2,repo3”。 ## 举些例子 diff --git a/action.yml b/action.yml index 806bde0a..00921359 100644 --- a/action.yml +++ b/action.yml @@ -32,6 +32,9 @@ inputs: white_list: description: "Low priority, the white list of mirror repo. like 'repo1,repo2,repo3'" default: '' + static_list: + description: "Only mirror repo in the static list, but don't get from repo api (the white/black list is still available). like 'repo1,repo2,repo3'" + default: '' runs: using: "docker" image: "Dockerfile" @@ -45,3 +48,4 @@ runs: - ${{ inputs.cache_path }} - ${{ inputs.black_list }} - ${{ inputs.white_list }} + - ${{ inputs.static_list }} \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index 582e57e0..a45cf91f 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -24,6 +24,7 @@ CACHE_PATH="${INPUT_CACHE_PATH}" WHITE_LIST="${INPUT_WHITE_LIST}" BLACK_LIST="${INPUT_BLACK_LIST}" +STATIC_LIST="${INPUT_STATIC_LIST}" if [[ "$ACCOUNT_TYPE" == "org" ]]; then SRC_LIST_URL_SUFFIX=orgs/$SRC_ACCOUNT/repos @@ -57,7 +58,11 @@ else exit 1 fi -SRC_REPOS=`curl $SRC_REPO_LIST_API | jq '.[] | .name' | sed 's/"//g'` +if [[ -z $STATIC_LIST ]]; then + SRC_REPOS=`curl $SRC_REPO_LIST_API | jq '.[] | .name' | sed 's/"//g'` +else + SRC_REPOS=`echo $STATIC_LIST | tr ',' ' '` +fi if [[ "$DST_TYPE" == "github" ]]; then DST_REPO_CREATE_API=https://api.github.com/$DST_CREATE_URL_SUFFIX