-
Notifications
You must be signed in to change notification settings - Fork 62
/
snapshot-publish
50 lines (39 loc) · 1.33 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
50
#!/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 $CURRENT_BRANCH"
cd $repoDir
git checkout -B $CURRENT_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://${API_TOKEN_GITHUB}:@github.com" > .git/credentials
git status
git add -A
if ! git diff-index --quiet HEAD; then
git commit -m "$commitMessage"
if "$CURRENT_BRANCH" == "master"; then
echo "Committing and pushing to master"
git tag "$commitSha"
git push origin master --tags
else
echo "Committing and pushing to $CURRENT_BRANCH"
git push -u origin $CURRENT_BRANCH --force
fi
fi
echo "Finished publishing snapshot build to $CURRENT_BRANCH"