Skip to content

Commit

Permalink
Fix non-empty check for invalid changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Miller committed Aug 30, 2019
1 parent 66dbb0c commit 2c08dcb
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions ci/build.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
#!/bin/sh

if [ "$TRAVIS_PULL_REQUEST" == false ] && [ "$TRAVIS_BRANCH" != "master" ] && [ "$TRAVIS_EVENT_TYPE" == "push" ]; then
changes=`git diff master...$TRAVIS_BRANCH --name-only | grep -i "fluentd-sumologic.yaml.tmpl\|fluent-bit-overrides.yaml\|prometheus-overrides.yaml\|falco-overrides.yaml"`
if [ -n "$changes" ]; then
if git --no-pager show -s --format="%an" . | grep -v -q -i "travis"; then
echo "Aborting due to manual changes detected in the following generated files: $changes"
exit 1
fi
fi
fi

VERSION="${TRAVIS_TAG:-0.0.0}"
VERSION="${VERSION#v}"
: "${DOCKER_TAG:=sumologic/kubernetes-fluentd}"
Expand Down Expand Up @@ -57,8 +47,22 @@ if [ -n "$GITHUB_TOKEN" ]; then
git config --global user.email "[email protected]"
git config --global user.name "Travis CI"
git remote add origin-repo https://${GITHUB_TOKEN}@github.com/SumoLogic/sumologic-kubernetes-collection.git > /dev/null 2>&1
git fetch origin-repo
git checkout $TRAVIS_BRANCH
fi

# Check for invalid changes to overrides yaml files
if [ -n "$GITHUB_TOKEN" ] && [ "$TRAVIS_PULL_REQUEST" == false ] && [ "$TRAVIS_BRANCH" != "master" ] && [ "$TRAVIS_EVENT_TYPE" == "push" ]; then
changes=`git diff origin-repo/master..$TRAVIS_BRANCH --name-only | grep -i "fluentd-sumologic.yaml.tmpl\|fluent-bit-overrides.yaml\|prometheus-overrides.yaml\|falco-overrides.yaml"`
if [ -n "$changes" ]; then
if git --no-pager show -s --format="%an" . | grep -v -q -i "travis"; then
echo "Aborting due to manual changes detected in the following generated files: $changes"
exit 1
fi
fi
fi

# Check for changes that require re-generating overrides yaml files
if [ "$TRAVIS_BRANCH" != "master" ] && [ "$TRAVIS_EVENT_TYPE" == "push" ] && [ -n "$GITHUB_TOKEN" ]; then
echo "Generating yaml from helm chart..."
echo "# This file is auto-generated." > deploy/kubernetes/fluentd-sumologic.yaml.tmpl
Expand All @@ -72,8 +76,6 @@ if [ "$TRAVIS_BRANCH" != "master" ] && [ "$TRAVIS_EVENT_TYPE" == "push" ] && [ -

if [[ $(git diff deploy/kubernetes/fluentd-sumologic.yaml.tmpl) ]]; then
echo "Detected changes in 'fluentd-sumologic.yaml.tmpl', committing the updated version to $TRAVIS_BRANCH..."
git fetch origin-repo
git checkout $TRAVIS_BRANCH
git add deploy/kubernetes/fluentd-sumologic.yaml.tmpl
git commit -m "Generate new 'fluentd-sumologic.yaml.tmpl'"
git push --quiet origin-repo "$TRAVIS_BRANCH"
Expand Down Expand Up @@ -120,8 +122,6 @@ if [ "$TRAVIS_BRANCH" != "master" ] && [ "$TRAVIS_EVENT_TYPE" == "push" ] && [ -

if [ "$(git diff deploy/helm/fluent-bit-overrides.yaml)" ] || [ "$(git diff deploy/helm/prometheus-overrides.yaml)" ] || [ "$(git diff deploy/helm/falco-overrides.yaml)" ]; then
echo "Detected changes in 'fluent-bit-overrides.yaml', 'prometheus-overrides.yaml' or 'falco-overrides.yaml', committing the updated version to $TRAVIS_BRANCH..."
git fetch origin-repo
git checkout $TRAVIS_BRANCH
git add deploy/helm/*-overrides.yaml
git commit -m "Generate new overrides yaml file(s)."
git push --quiet origin-repo "$TRAVIS_BRANCH"
Expand Down

0 comments on commit 2c08dcb

Please sign in to comment.