-
Notifications
You must be signed in to change notification settings - Fork 4
47 lines (42 loc) · 1.5 KB
/
shasum.yml
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
---
name: Check Shasums
on: [pull_request]
jobs:
shasum:
name: Check images are ok
runs-on: ubuntu-latest
steps:
# Checks out a copy of your repository on the ubuntu-latest machine
- name: Checkout code
uses: actions/checkout@v4
with:
# Make sure the actual branch is checked out when running on PR
ref: ${{ github.event.pull_request.head.sha }}
# Full git history needed to get proper list of changed files
fetch-depth: 0
# Installs yq
- name: Install yq
run: |
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CC86BB64
sudo add-apt-repository -y ppa:rmescandon/yq
sudo apt update
sudo apt install -y -q yq
# Runs the Super-Linter action
- name: Calculate the sum for new images
run: |
for f in $(git diff --name-only ${{ github.event.pull_request.base.sha }} | grep "appdb.*\.yaml")
do
[ -e "$f" ] || continue
echo "Testing $f"
url=$(yq eval .appdb.url "$f")
curl -I "$url" || exit 1
# now download and shasum
sha_url=$(curl -s "$url" | sha512sum | cut -f1 -d"-" | tr -d "[:space:]")
sha_appdb=$(yq eval .appdb.sha512 "$f")
if [ "$sha_url" != "$sha_appdb" ]
then
echo "SHA SUM does not match $sha_url $sha_appdb!"
# don't try to download anything else
exit 1
fi
done