[Buildkite] Fix docs bypass for origin/master divergences (#764)

If origin/master diverges beyond the initial fork-point on branches or external forks, the `git merge-base` command exits unsuccessfully. This will cause commits to incorrectly be recognised as a docs bypass. This change will catch the unsuccessful exit and treat it as a normal CI/CD run.

Examples:
- https://buildkite.com/authelia/authelia/builds/932
- https://buildkite.com/authelia/authelia/builds/933
- https://buildkite.com/authelia/authelia/builds/941
pull/765/head
Amir Zarrinkafsh 2020-03-22 00:42:29 +11:00 committed by GitHub
parent 0ecbdc6f84
commit 93abf699b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 12 deletions

View File

@ -1,6 +1,9 @@
#!/bin/bash #!/bin/bash
set -u set -u
DIVERGED=$(git merge-base --fork-point origin/master > /dev/null; echo $?)
if [[ $DIVERGED -eq 0 ]]; then
if [[ $BUILDKITE_TAG == "" ]]; then if [[ $BUILDKITE_TAG == "" ]]; then
if [[ $BUILDKITE_BRANCH == "master" ]]; then if [[ $BUILDKITE_BRANCH == "master" ]]; then
CI_DOCS_BYPASS=$(git diff --name-only HEAD~1 | sed -rn '/^docs\/.*/!{q1}' && echo true || echo false) CI_DOCS_BYPASS=$(git diff --name-only HEAD~1 | sed -rn '/^docs\/.*/!{q1}' && echo true || echo false)
@ -10,6 +13,9 @@ if [[ $BUILDKITE_TAG == "" ]]; then
else else
CI_DOCS_BYPASS="false" CI_DOCS_BYPASS="false"
fi fi
else
CI_DOCS_BYPASS="false"
fi
cat << EOF cat << EOF
env: env:

View File

@ -1,6 +1,9 @@
#!/bin/bash #!/bin/bash
set -u set -u
DIVERGED=$(git merge-base --fork-point origin/master > /dev/null; echo $?)
if [[ $DIVERGED -eq 0 ]]; then
if [[ $BUILDKITE_TAG == "" ]]; then if [[ $BUILDKITE_TAG == "" ]]; then
if [[ $BUILDKITE_BRANCH == "master" ]]; then if [[ $BUILDKITE_BRANCH == "master" ]]; then
CI_DOCS_BYPASS=$(git diff --name-only HEAD~1 | sed -rn '/^docs\/.*/!{q1}' && echo true || echo false) CI_DOCS_BYPASS=$(git diff --name-only HEAD~1 | sed -rn '/^docs\/.*/!{q1}' && echo true || echo false)
@ -14,6 +17,9 @@ if [[ $BUILDKITE_TAG == "" ]]; then
else else
CI_DOCS_BYPASS="false" CI_DOCS_BYPASS="false"
fi fi
else
CI_DOCS_BYPASS="false"
fi
cat << EOF cat << EOF
env: env: