-
Notifications
You must be signed in to change notification settings - Fork 27
/
move.sh
executable file
·47 lines (38 loc) · 1.11 KB
/
move.sh
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
#!/bin/bash
# Define some colors
RED='\033[31m'
GREEN='\033[32m'
NC='\033[0m' # No Color
# Get version from GitHub environment variable
version=${VERSION}
# Check if version is provided
if [ -z "$version" ]
then
echo -e "${RED}No version specified. No targets will be moved. Exiting...${NC}"
exit 1
fi
# Convert the YAML file to JSON
json=$(python -c "import sys, yaml, json; json.dump(yaml.safe_load(sys.stdin), sys.stdout)" < sources.yaml)
# Check if json is empty
if [ -z "$json" ]
then
echo -e "${RED}Failed to convert YAML to JSON. Exiting...${NC}"
exit 1
fi
# Parse the JSON file to get the target
target=$(echo $json | jq -r --arg version "$version" '.[$version].target[]')
# Check if target is empty
if [ -z "$target" ]
then
echo -e "${RED}Failed to parse JSON. Exiting...${NC}"
exit 1
fi
# Add 'kernel' to the target path
target="${GITHUB_WORKSPACE}/kernel/$target"
# Check the KERNELSU environment variable and move the target to the appropriate directory
if [ "${KERNELSU}" == "true" ]
then
mv $target "${GITHUB_WORKSPACE}/outw/true"
else
mv $target "${GITHUB_WORKSPACE}/outw/false"
fi