forked from bullhorn/novo-elements
-
Notifications
You must be signed in to change notification settings - Fork 0
/
snapshot-publish
49 lines (37 loc) · 1.28 KB
/
snapshot-publish
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
#!/bin/bash
set -o errexit -o nounset
buildDir="dist/novo-elements"
commitSha=$(git rev-parse --short HEAD)
commitAuthorName=$(git --no-pager show -s --format='%an' HEAD)
commitAuthorEmail=$(git --no-pager show -s --format='%ae' HEAD)
commitMessage=$(git log --oneline -n 1)
repoName="novo-elements-snapshot"
repoUrl="https://github.com/bullhorn/novo-elements-snapshot.git"
repoDir="snapshot"
echo "Cloning $repoUrl into $repoDir"
git clone $repoUrl $repoDir
echo "Changing branch to $TRAVIS_BRANCH"
cd $repoDir
git checkout -B $TRAVIS_BRANCH
cd ..
echo "Cleaning snapshot repo and moving build files into it"
rm -rf $repoDir/*
cp -r $buildDir/* $repoDir
cd $repoDir
# Prepare Git for pushing the artifacts to the repository.
git config user.name "$commitAuthorName"
git config user.email "$commitAuthorEmail"
git config credential.helper "store --file=.git/credentials"
echo "https://${SNAPSHOT_GIT_TOKEN}:@github.com" > .git/credentials
git status
git add -A
git commit -m "$commitMessage"
if [ "$TRAVIS_BRANCH" == "master" ]; then
echo "Committing and pushing to master"
git tag "$commitSha"
git push origin master --tags
else
echo "Committing and pushing to $TRAVIS_BRANCH"
git push -u origin $TRAVIS_BRANCH --force
fi
echo "Finished publishing snapshot build to $TRAVIS_BRANCH"