forked from argoproj/argo-workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
maybe-skip-job.sh
executable file
·43 lines (37 loc) · 831 Bytes
/
maybe-skip-job.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
#!/bin/bash
set -eux -o pipefail
branch=$(git rev-parse --abbrev-ref=loose HEAD | sed 's/heads\///')
job=$1
# always run on master
[ "$branch" = master ] && exit
# always run on release branch
[[ "$branch" =~ release-.* ]] && exit
# tip - must use origin/master for CircleCI
diffs=$(git diff --name-only origin/master)
# if certain files change, then we always run
[ "$(echo "$diffs" | grep 'Dockerfile\|Makefile')" != "" ] && exit
# if there are changes to this areas, we must run
rx=
case $job in
codegen)
rx='api/\|hack/\|examples/\|manifests/\|pkg/'
;;
docker-build)
# we only run on master as this rarely ever fails
circleci step halt
exit
;;
e2e-*)
rx='manifests/\|\.go'
;;
test)
rx='\.go'
;;
ui)
rx='ui/'
;;
esac
if [ "$(echo "$diffs" | grep "$rx")" = "" ]; then
circleci step halt
exit
fi