Merge branch 'main' into staging
This commit is contained in:
commit
7b99f92704
21
.github/workflows/main.yml
vendored
Normal file
21
.github/workflows/main.yml
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
#should deny
|
||||
name: Verify
|
||||
on: [pull_request]
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Prepare repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt install -y unzip jq
|
||||
|
||||
- name: Run verify script
|
||||
run: |
|
||||
cd scripts
|
||||
bash verify.sh
|
||||
if [ $? -eq 1 ]; then
|
||||
exit 1
|
||||
fi
|
67
scripts/verify.sh
Executable file
67
scripts/verify.sh
Executable file
@ -0,0 +1,67 @@
|
||||
#!/bin/bash
|
||||
|
||||
function checkVersionAndId {
|
||||
idArg=$1
|
||||
versionArg=$2
|
||||
|
||||
themeId="$(unzip -p "${idArg}.zip" theme.json | jq -r '.id')"
|
||||
if [[ $idArg != "$themeId" ]]; then
|
||||
echo "Theme id for $idArg does NOT match!"
|
||||
exit 1
|
||||
else
|
||||
echo "theme ids match"
|
||||
fi
|
||||
|
||||
themeVersion="$(unzip -p "${idArg}.zip" theme.json | jq -r '.version')"
|
||||
if [[ "$versionArg" != "$themeVersion" ]]; then
|
||||
echo "Versions for $idArg do NOT match!"
|
||||
exit 1
|
||||
else
|
||||
echo "versions match"
|
||||
fi
|
||||
}
|
||||
|
||||
zip_dir="../data/themes"
|
||||
|
||||
# Change to the specified zip_dir
|
||||
cd "$zip_dir" || exit 1
|
||||
|
||||
|
||||
json_file="../themes.json"
|
||||
|
||||
# Read the contents of the JSON file
|
||||
json=$(cat "$json_file")
|
||||
|
||||
# Extract the "sha256" and "id" values using jq
|
||||
themes=$(echo "$json" | jq -r '.themes[] | "\(.sha256) \(.id) \(.version)"')
|
||||
|
||||
# Loop through each theme and print the "sha256" and "id" values
|
||||
while read -r sha256 id version; do
|
||||
|
||||
file="${id}.zip"
|
||||
if [[ -f "$file" ]]; then
|
||||
# Calculate the SHA256 hash
|
||||
sha256sum_output=$(sha256sum "$file")
|
||||
sha256_hash=${sha256sum_output%% *}
|
||||
|
||||
# Check if match
|
||||
if [[ "$sha256" == "$sha256_hash" ]]; then
|
||||
echo "Theme $file hash matches hash in themes.json"
|
||||
else
|
||||
echo "Theme $file hash doe NOT match hash in themes.json!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check inside zip file
|
||||
checkVersionAndId "$id" "$version"
|
||||
|
||||
echo
|
||||
|
||||
else
|
||||
echo "Theme $file not found!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
done <<< "$themes"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user