Add allows check for sync
This commit is contained in:
parent
5b89b1d521
commit
5a3f3841d6
|
@ -64,6 +64,10 @@ jobs:
|
||||||
gh issue edit ${{ github.event.issue.number }} --add-label "sync image succeeded" -b "IMAGE SYNC"
|
gh issue edit ${{ github.event.issue.number }} --add-label "sync image succeeded" -b "IMAGE SYNC"
|
||||||
gh issue close ${{ github.event.issue.number }} --reason "completed"
|
gh issue close ${{ github.event.issue.number }} --reason "completed"
|
||||||
|
|
||||||
|
if ! ./hack/verify-allows.sh ./allows.txt "${ORIGIN_IMAGE}"; then
|
||||||
|
gh issue comment ${{ github.event.issue.number }} -b "这个镜像不在白名单列表里, 在未来可能将无法访问<br>将其添加到[白名单](https://github.com/DaoCloud/public-image-mirror/blob/main/allows.txt)"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Fail Sync
|
- name: Fail Sync
|
||||||
if: failure()
|
if: failure()
|
||||||
env:
|
env:
|
||||||
|
|
|
@ -59,6 +59,10 @@ jobs:
|
||||||
gh issue edit ${{ github.event.issue.number }} --add-label "sync image succeeded" -b "IMAGE SYNC"
|
gh issue edit ${{ github.event.issue.number }} --add-label "sync image succeeded" -b "IMAGE SYNC"
|
||||||
gh issue close ${{ github.event.issue.number }} --reason "completed"
|
gh issue close ${{ github.event.issue.number }} --reason "completed"
|
||||||
|
|
||||||
|
if ! ./hack/verify-allows.sh ./allows.txt "${ORIGIN_IMAGE}"; then
|
||||||
|
gh issue comment ${{ github.event.issue.number }} -b "这个镜像不在白名单列表里, 在未来可能将无法访问<br>将其添加到[白名单](https://github.com/DaoCloud/public-image-mirror/blob/main/allows.txt)"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Fail Sync
|
- name: Fail Sync
|
||||||
if: failure()
|
if: failure()
|
||||||
run: |
|
run: |
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
file=$1
|
||||||
|
|
||||||
|
image=$2
|
||||||
|
|
||||||
|
function check_allows() {
|
||||||
|
local file=$1
|
||||||
|
local image=$2
|
||||||
|
while read line; do
|
||||||
|
if [[ "${line}" == *"**" ]]; then
|
||||||
|
if [[ "${image}" == "${line%\*\*}"* ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
elif [[ "${line}" == *"*" ]]; then
|
||||||
|
if [[ "${image}" == "${line%\*}"* ]]; then
|
||||||
|
if [[ "${image#"${line%\*}"}" != *"/"* ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done <"${file}"
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
check_allows "${file}" "${image}"
|
Loading…
Reference in New Issue