-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdater.sh
executable file
·67 lines (55 loc) · 1.71 KB
/
updater.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
64
65
66
67
#!/bin/bash
if [ "$1" = cleanup ]; then
rm -rf .github .gitignore .nojekyll *.sh CNAME
exit 0
fi
set -e
REMOTE=iBug/image
BRANCH=master
REMOTE2=iBug-web/image
BRANCH2=master
ecode=0
export SSH_AUTH_SOCK=none
mkdir -p ~/.ssh
# Prepare SSH stuff
if [ -z "$SSH_KEY_E" ]; then
echo "SSH key not found!" >&2
ecode=1
elif git log -1 --pretty=format:%s | grep -qiF '[squash]'; then
base64 -d <<< "$SSH_KEY_E" | gunzip -c > ~/.ssh/id_rsa
chmod 400 ~/.ssh/id_rsa
export GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa"
git clone --depth=1 --branch="$BRANCH" "[email protected]:$REMOTE.git" work
cd work
shopt -s nullglob
git checkout --orphan temp
git add -A
git -c user.name=GitHub -c [email protected] \
commit -m "Auto squash from GitHub Actions [ci skip]"
git branch -M "$BRANCH"
git push origin +HEAD:"$BRANCH"
fi
if [ -z "$SSH_KEY_E2" ]; then
echo "Alternate SSH key not found!" >&2
ecode=1
else
base64 -d <<< "$SSH_KEY_E2" | gunzip -c > ~/.ssh/id_ecdsa
chmod 400 ~/.ssh/id_ecdsa
export GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_ecdsa"
rm -rf .github .gitignore *.sh CNAME
git checkout --orphan temp
git add -A
git -c user.name=GitHub -c [email protected] \
commit -m "Auto squash from GitHub Actions [ci skip]"
git remote add origin2 "[email protected]:$REMOTE2.git"
git push origin2 +HEAD:"$BRANCH2"
fi
if [ -z "$NETLIFY_AUTH_TOKEN" -o -z "$NETLIFY_SITE_ID" ]; then
echo "No Netlify credentials found, skipping Netlify." >&2
else
rsync -vr --delete --exclude={.*,CNAME,node_modules,package.json,*.sh} ./ _temp/
mkdir -p _temp
sudo npm install --global netlify-cli
npx netlify deploy --dir=_temp --prod
fi
exit $ecode