forked from docker-practice/docker-registry-cn-mirror-test
-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (108 loc) · 4.63 KB
/
ci.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
on:
push:
schedule:
- cron: '0 0 */1 * *'
workflow_dispatch:
name: Test Registry
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
ci:
runs-on: ubuntu-latest
steps:
- name: checkout codes
uses: actions/checkout@v2
- name: install docker
if: ${{ false }}
uses: docker-practice/actions-setup-docker@master
with:
docker_version: "20.10"
docker_channel: test
docker_buildx: false
- run: docker version
if: ${{ false }}
- run: docker info
if: ${{ false }}
- name: install wget,gh
run: sudo apt install -yq wget && wget -q https://github.com/cli/cli/releases/download/v2.14.3/gh_2.14.3_linux_amd64.tar.gz && tar xf gh_*.tar.gz && cp gh_*_linux_amd64/bin/gh /usr/local/bin/ && gh - && rm -rf gh*
- name: install yq
run: gh release download --repo mikefarah/yq -p 'yq_linux_amd64' && mv yq_linux_amd64 /usr/local/bin/yq && chmod a+x /usr/local/bin/yq
- name: test skopeo
run: |
gh release download --repo lework/skopeo-binary -p 'skopeo-linux-amd64'
mv skopeo-linux-amd64 /usr/local/bin/skopeo
chmod a+x /usr/local/bin/skopeo
skopeo list-tags docker://hub-mirror.c.163.com/library/nginx | yq -P > registry/nginx.inspect.yaml
- name: get browser download url
id: skopeo
run: |
img="lework/skopeo-binary"
rm -rf assets || mkdir assets
gh api repos/$img/releases/latest | yq -P '.assets[]|select(has("browser_download_url"))|.browser_download_url' | tee > skopeo.yaml
- name: show download url
run: echo "${{ steps.skopeo.outputs.stdout }}"
- name: test
id: test
run: |
echo "::set-output name=timestamp::$(date)\n"
- name: get my starred repos
run: |
gh api users/xtha/starred | yq -P | tee starred_repos.yaml
- name: get browser download url of my starred repos
run: |
user="xtha"
repos=$(gh api users/$user/starred | yq -P ".[].full_name")
rm -f fastgit.txt
for repo in $repos
do
echo "$repo"
gh api repos/$repo/releases/latest && gh api repos/$repo/releases/latest | yq -P '.assets[]|select(has("browser_download_url"))|.browser_download_url'
gh api repos/$repo/releases/latest && gh api repos/$repo/releases/latest | yq -P '.assets[]|select(has("browser_download_url"))|.browser_download_url' | sed -n 's/github.com/hub.fastgit.xyz/' >> fastgit.txt
done
- name: Run read-yaml action
if: ${{ false }}
id: yaml-data
uses: KJ002/read-yaml@main # You may wish to replace main with a version tag such as '1.6' etc.
with:
file: './registry.yaml' # File to read from
key-path: '["registry", "hosts"]' # Access the runs key then the using key and retuns the value.
- name: yq load yaml data from yaml file
id: yaml_file
run: yq .registry.hosts.[] registry.yaml
- name: Display read-yaml output
run: echo "${{ steps.yaml_file.outputs.stdout}}, ${{ steps.test.outputs.timestamp }}"
- name: Test registry
run: |
image="library/nginx"
test -d registry || mkdir -pv registry
for registry in $(yq .registry.hosts[] registry.yaml)
do
echo ::group::Test $registry/$image
SKOPEO_CMD="skopeo inspect docker://$registry/$image"
DOCKER_CMD="docker pull $registry/$image"
time `$SKOPEO_CMD` \
&& (echo -e "\033[32m$registry is good\033[0m" \
; echo "::warning file=README.md,line=1,col=0::OK [ $registry ] is good") \
|| (echo -e "\033[31m$registry is outdated\033[0m" \
; echo "::error file=README.md,line=1,col=0::X [ $registry ] is outdated")
echo ::endgroup::
done
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: upload assets/*.yaml
branch: master
tagging_message: 'v1.0.0'
- name: upload artifacts
uses: actions/upload-artifact@v2
with:
name: skopeo-linux-amd64
path: |
/usr/local/bin/skopeo
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
/usr/local/bin/skopeo
/usr/local/bin/yq
/usr/local/bin/gh