[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/941pull/765/head
parent
0ecbdc6f84
commit
93abf699b8
|
@ -1,12 +1,18 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -u
|
set -u
|
||||||
|
|
||||||
if [[ $BUILDKITE_TAG == "" ]]; then
|
DIVERGED=$(git merge-base --fork-point origin/master > /dev/null; echo $?)
|
||||||
|
|
||||||
|
if [[ $DIVERGED -eq 0 ]]; 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)
|
||||||
else
|
else
|
||||||
CI_DOCS_BYPASS=$(git diff --name-only `git merge-base --fork-point origin/master` | sed -rn '/^docs\/.*/!{q1}' && echo true || echo false)
|
CI_DOCS_BYPASS=$(git diff --name-only `git merge-base --fork-point origin/master` | sed -rn '/^docs\/.*/!{q1}' && echo true || echo false)
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
CI_DOCS_BYPASS="false"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
CI_DOCS_BYPASS="false"
|
CI_DOCS_BYPASS="false"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -u
|
set -u
|
||||||
|
|
||||||
if [[ $BUILDKITE_TAG == "" ]]; then
|
DIVERGED=$(git merge-base --fork-point origin/master > /dev/null; echo $?)
|
||||||
|
|
||||||
|
if [[ $DIVERGED -eq 0 ]]; 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)
|
||||||
else
|
else
|
||||||
|
@ -11,6 +14,9 @@ if [[ $BUILDKITE_TAG == "" ]]; then
|
||||||
if [[ $CI_DOCS_BYPASS == "true" ]]; then
|
if [[ $CI_DOCS_BYPASS == "true" ]]; then
|
||||||
cat .buildkite/annotations/documentation | buildkite-agent annotate --style "info" --context "ctx-info"
|
cat .buildkite/annotations/documentation | buildkite-agent annotate --style "info" --context "ctx-info"
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
CI_DOCS_BYPASS="false"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
CI_DOCS_BYPASS="false"
|
CI_DOCS_BYPASS="false"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue