From 155ec1c1b5a59e144dc96e425da8327126fc2d39 Mon Sep 17 00:00:00 2001 From: Shiming Zhang Date: Tue, 18 Jan 2022 16:36:33 +0800 Subject: [PATCH] Add check image exists --- .../workflows/{verify-fmt.yml => verify-rp.yml} | 7 +++++-- hack/verify-image.sh | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) rename .github/workflows/{verify-fmt.yml => verify-rp.yml} (67%) create mode 100755 hack/verify-image.sh diff --git a/.github/workflows/verify-fmt.yml b/.github/workflows/verify-rp.yml similarity index 67% rename from .github/workflows/verify-fmt.yml rename to .github/workflows/verify-rp.yml index 2332d6d..cd9c5d9 100644 --- a/.github/workflows/verify-fmt.yml +++ b/.github/workflows/verify-rp.yml @@ -1,11 +1,11 @@ -name: Verify Format +name: Verify PR on: pull_request: branches: [main] jobs: - Patch: + Check: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -15,3 +15,6 @@ jobs: - name: Verify mirror.txt run: | ./hack/verify-fmt.sh mirror.txt || { echo "Please run './hack/fmt.sh mirror.txt'"; exit 1; } + - name: Verify Image Exists + run: | + ./hack/verify-image.sh https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}.patch diff --git a/hack/verify-image.sh b/hack/verify-image.sh new file mode 100755 index 0000000..042ef24 --- /dev/null +++ b/hack/verify-image.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +patch_url=$1 + +file=mirror.txt + +cp "${file}" "${file}.bak" + +git apply -R <(curl -fsSL "${patch_url}") + +list=$(diff --unified "${file}" "${file}.bak" | grep -e '^+\w' | sed 's/^+//') + +for image in ${list}; do + skopeo inspect --raw "docker://${image}" || { echo "Not Found ${image}" ; exit 1; } +done