Skip to content

Commit

Permalink
Add static list support (#23)
Browse files Browse the repository at this point in the history
Closes: #24
  • Loading branch information
Yikun authored Mar 27, 2020
1 parent 6a287eb commit 1c23744
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/verify-on-ubuntu-user.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
dst: gitee/yikunkero
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
dst_token: ${{ secrets.GITEE_TOKEN }}
white_list: 'hub-mirror-action'
static_list: 'hub-mirror-action,hashes,simple-spring'
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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”。

## 举些例子

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -45,3 +48,4 @@ runs:
- ${{ inputs.cache_path }}
- ${{ inputs.black_list }}
- ${{ inputs.white_list }}
- ${{ inputs.static_list }}
7 changes: 6 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1c23744

Please sign in to comment.