-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_shfmt.sh
executable file
·42 lines (34 loc) · 984 Bytes
/
run_shfmt.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
#!/usr/bin/env bash
set -eu
set -o pipefail
# Script To Run shfmt
# Check Docker
if [[ -z "$(command -v docker)" ]]; then
echo "Docker not found!"
echo "Exiting..."
exit 1
fi
# Color
GREEN="\033[1;32m"
YELLOW="\033[1;33m"
NC="\033[0m"
# Variables
GH_REF="github.com/crazyuploader/BASH.git"
# Run shfmt
docker run --rm -v "${PWD}":/mnt -w /mnt mvdan/shfmt -w .
# Making Shell Scripts Executables
LIST_FILES="$(find . -path ./.git -prune -o -name '*.sh' -print | sed 's|^./||' | sort)"
for file in ${LIST_FILES}; do
sudo chmod +x "${file}"
done
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions"
echo ""
if [[ -z $(git status --porcelain) ]]; then
echo -e "${GREEN} Nothing to commit.${NC}"
else
git add .
git commit -m "Run shfmt & Make Shell Scripts Executable"
git push https://crazyuploader:"${GITHUB_TOKEN}"@"${GH_REF}" HEAD:"${GITHUB_REF}"
echo -e "${YELLOW}Updates Pushed to https://${GH_REF}"
fi