Skip to content

Test Registry

Test Registry #851

Workflow file for this run

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