forked from OxideMod/Oxide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·51 lines (39 loc) · 2.07 KB
/
deploy.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
#!/bin/bash
ORG_NAME=${TRAVIS_REPO_SLUG%/*}
REPO_NAME=${TRAVIS_REPO_SLUG#*/}
function die_with { echo "$*" >&2; exit 1; }
echo "Are you Travis?"
if [ ! $TRAVIS ]; then die_with "You are not Travis!"; fi
echo "Checking if commit is a pull request"
if [ $TRAVIS_PULL_REQUEST == true ]; then die_with "Skipping deployment for pull request!"; fi
echo "Configuring git credentials"
git config --global user.email "travis@travis-ci.org" || die_with "Failed to configure git user email!"
git config --global user.name "Travis" || die_with "Failed to configure git user name!"
echo "Cloning Snapshots repo using token"
GIT_REPO="https://$GITHUB_TOKEN@github.com/$ORG_NAME/Snapshots.git"
git clone --depth 1 $GIT_REPO $HOME/Snapshots >/dev/null || die_with "Failed to clone Snapshots repository!"
cd $HOME/Snapshots || die_with "Failed to change to Snapshots directory!"
ATTEMPT=0
until [ $ATTEMPT -ge 5 ]; do
echo "Fetching changes from Snapshots repository"
git fetch origin master || die_with "Failed to fetch changes to Snapshots!"
git reset --hard origin/master
echo "Bundling and compressing file(s) to Snapshots"
for d in $TRAVIS_BUILD_DIR/Bundles/*; do
GAME="${d##*/}"
cd $TRAVIS_BUILD_DIR/Bundles/$GAME && zip -FS -vr9 $HOME/Snapshots/$REPO_NAME-$GAME.zip . || die_with "Failed to create game bundles!"
done
cd $HOME/Snapshots || die_with "Failed to change to Snapshots directory!"
echo "Adding and committing changes"
git add . || die_with "Failed to add files for commit!"
COMMIT_MESSAGE="$REPO_NAME build $TRAVIS_BUILD_NUMBER from https://github.com/$TRAVIS_REPO_SLUG/commit/${TRAVIS_COMMIT:0:7}"
git commit -m "$COMMIT_MESSAGE" || die_with "Failed to commit files!"
git config http.postBuffer 52428800
git config pack.windowMemory "32m"
git repack --max-pack-size=100M -a -d
echo "Pushing build to GitHub"
git push -q origin master >/dev/null && break || die_with "Failed to push to GitHub!"
ATTEMPT=$[$ATTEMPT+1]
sleep 15
done || die_with "Failed to deploy build!"
echo "Deployment cycle completed. Happy developing!"