-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathupdate-ghactions.sh
executable file
·64 lines (57 loc) · 1.29 KB
/
update-ghactions.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#! /bin/sh
# all targets are at local and in one directory
dirs=`find . -maxdepth 1 -type d`
# defs
check_main="git for-each-ref --format='%(refname:short)' | grep '^main$'"
ghactions='.github/workflows'
commit_msg='Updated GHActions file see https://github.com/immersive-web/administrivia/issues/151'
gitpush="git push"
for dir in $dirs;
do
if [ ! -d "${dir}/.git" ]; then
echo "Directory $dir is not git repository"
continue
fi
echo "Working on $dir"
cd $dir
out=`eval ${check_main}`
if [ ! "x$out" = "xmain" ]; then
echo "$dir does not have main branch"
cd ..
continue
fi
git checkout -q main
if [ $? -gt 0 ]; then
echo "ERROR: git checkout main failed on $dir"
cd ..
continue
fi
git pull -q
if [ $? -gt 0 ]; then
echo "ERROR: git pull failed on $dir"
cd ..
continue
fi
if [ ! -d "$ghactions" ]; then
echo "$dir does not have GHActions directory"
cd ..
continue
fi
# Write your operation here
cp ../deploy.yml .github/workflows/deploy.yml
# commit and push
git commit -a -m "$commit_msg"
if [ $? -gt 0 ]; then
echo "Commit failed for $dir"
cd ..
continue
fi
out=`eval ${gitpush}`
if [ $? -gt 0 ]; then
echo "Push failed for $dir"
cd ..
continue
fi
echo "Finished for $dir"
cd ..
done