-
Notifications
You must be signed in to change notification settings - Fork 2
/
make_executable.sh
executable file
·48 lines (46 loc) · 1.56 KB
/
make_executable.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
48
#!/usr/bin/env bash
#
# Add executable permission to '*.py' files in current directories
# and subdirectories
#
# Colors
NC="\033[0m"
GREEN="\033[1;32m"
YELLOW="\033[1;33m"
GH_REF="github.com/crazyuploader/Python.git"
git remote remove origin
git remote add origin https://"${GH_REF}"
git fetch --all
echo ""
echo -e "${GREEN}" "Available files -${NC}"
LIST_FILES="$(find . -path ./.git -prune -o -name '*.py' -print | sed 's|^./||')"
echo "${LIST_FILES}"
echo ""
echo "Adding Executable Permission"
echo ""
for file in ${LIST_FILES}; do
chmod +x "${file}"
done
CHANGES=$(git status --porcelain)
if [[ -n ${CHANGES} ]]; then
CHANGED_FILES=$(git status --porcelain | cut -d " " -f 3)
echo -e "${YELLOW}Changed Files${NC}"
echo ""
for file in ${CHANGED_FILES}; do echo -e "${GREEN}${file}${NC}"; ((FILES = FILES + 1)); done
echo -e "${GREEN}${FILES} file(s) changed.${NC}"
echo ""
fi
if [[ -z ${CHANGES} ]]; then
echo -e "${GREEN}Nothing to commit${NC}"
else
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions"
git add .
git commit -m "Adding Executable Permission [skip ci]" \
-m "" \
-m "Add Executable Permission:" \
-m "$(for changes in ${CHANGED_FILES}; do echo "${changes}"; done)"
git push https://crazyuploader:"${GITHUB_TOKEN}"@"${GH_REF}" HEAD:"${GITHUB_REF}"
echo ""
echo -e "${YELLOW}Changes pushed to branch '${GITHUB_REF}' at https://github.com/crazyuploader/Python/tree/${GITHUB_REF}"
fi