forked from theia-ide/theia-apps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
commit_screenshots.sh
executable file
·48 lines (39 loc) · 1.61 KB
/
commit_screenshots.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
#!/bin/bash
# Copyright 2019 D.W.J. Bosman
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
set -e # Exit with a non zero exit code when a command fails
SOURCE_BRANCH="master"
# the screenshots will be committed in this branch
TARGET_BRANCH="bugs"
# Add the GITHUB_TOKEN to the url so that travis is able to commit
REPO=`git config remote.origin.url`
AUTH_REPO=${REPO/https:\/\/github.com\//https://${GITHUB_TOKEN}@github.com/}
SHA=`git rev-parse --verify HEAD`
git config user.name "Travis CI"
git config user.email "$COMMIT_AUTHOR_EMAIL"
git fetch --depth 1 origin $TARGET_BRANCH:$TARGET_BRANCH
git checkout $TARGET_BRANCH
# Empty the branch, ignore error if alrady empty
git rm -r . || true
# Add all png files
find . -name '*.png' | xargs git add
# If Git indicates that there are no changes, the script will exit without comitting.
if git diff --staged --quiet; then
echo "No changes to the output on this push; exiting."
exit 0
fi
# Commit
git commit --message "Travis build: $TRAVIS_BUILD_NUMBER"
git remote add origin-results ${AUTH_REPO} > /dev/null 2>&1
git push --quiet --set-upstream origin-results $TARGET_BRANCH