storj/satellite/admin/ui/build-if-changed.sh
Márton Elek 96b88e286e build: fix conditional run of web builds
Jenkins doesn't do a very good job with identifying what has been changed.

While it has a syntax to defined patterns, it compares the current build with the previous build (in case of git-verify it can be a totally different branch) instead of checking the HEAD commit.

This patch introduces shell scripts to do this better:
 * It doesn't depend on Jenkins any more
 * It can be executed locally
 * It can detect web changes properly (see the relation change as an example).

Change-Id: I9d37775e3818c08c4aa96ffb78f84d57f28a2c95
2022-08-11 14:34:44 +00:00

30 lines
447 B
Bash
Executable File

#!/usr/bin/env bash
# Copyright (C) 2022 Storj Labs, Inc.
# See LICENSE for copying information.
cd "$(dirname "${BASH_SOURCE[0]}")"
set -xuo pipefail
CHECK=satellite/admin/ui
CHANGED=false
#last commit
git diff HEAD HEAD~1 --name-only | grep $CHECK
if [ $? -eq 0 ]; then
CHANGED=true
fi
#working directory
git diff --name-only | grep $CHECK
if [ $? -eq 0 ]; then
CHANGED=true
fi
if [ $CHANGED == "true" ]; then
./build.sh
fi