Fix CI config to check if branch is master before skipping (#9140)

Related to: https://github.com/influxdata/telegraf/pull/9076

In order to support skipping a job depending on file changes, only works on non-master branches. This pull requests updates the config to check the current branch.
This commit is contained in:
Sebastian Spaink 2021-04-16 16:24:50 -05:00 committed by GitHub
parent 1a86fd1a2d
commit 9d163f6a83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -27,11 +27,11 @@ executors:
commands:
check-changed-files-or-halt:
steps:
- run: git diff master --name-only --no-color | egrep -e "^(\.circleci\/.*)|(.*\.(go|mod|sum))|Makefile$" || circleci step halt
- run: ./scripts/check-file-changes.sh
check-changed-files-or-halt-windows:
steps:
- run:
command: git diff master --name-only --no-color | egrep -e "^(\.circleci\/.*)|(.*\.(go|mod|sum))|Makefile$" || circleci step halt
command: ./scripts/check-file-changes.sh
shell: bash.exe
test-go:
parameters:

7
scripts/check-file-changes.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
BRANCH="$(git rev-parse --abbrev-ref HEAD)"
echo $BRANCH
if [[ "$BRANCH" != "master" ]]; then
git diff master --name-only --no-color | egrep -e "^(\.circleci\/.*)|(.*\.(go|mod|sum))|Makefile$" || circleci step halt;
fi