mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 01:13:23 -04:00
[CI] Auto commit changes in auto-generated files (#127811)
This commit is contained in:
parent
6084c972ee
commit
76f491b81d
5 changed files with 40 additions and 9 deletions
|
@ -19,7 +19,7 @@ if ! yarn kbn bootstrap; then
|
|||
fi
|
||||
|
||||
if [[ "$DISABLE_BOOTSTRAP_VALIDATION" != "true" ]]; then
|
||||
verify_no_git_changes 'yarn kbn bootstrap'
|
||||
check_for_changed_files 'yarn kbn bootstrap'
|
||||
fi
|
||||
|
||||
###
|
||||
|
|
|
@ -14,17 +14,46 @@ is_pr() {
|
|||
false
|
||||
}
|
||||
|
||||
verify_no_git_changes() {
|
||||
check_for_changed_files() {
|
||||
RED='\033[0;31m'
|
||||
YELLOW='\033[0;33m'
|
||||
C_RESET='\033[0m' # Reset color
|
||||
|
||||
SHOULD_AUTO_COMMIT_CHANGES="${2:-}"
|
||||
GIT_CHANGES="$(git ls-files --modified -- . ':!:.bazelrc')"
|
||||
|
||||
if [ "$GIT_CHANGES" ]; then
|
||||
echo -e "\n${RED}ERROR: '$1' caused changes to the following files:${C_RESET}\n"
|
||||
echo -e "$GIT_CHANGES\n"
|
||||
echo -e "\n${YELLOW}TO FIX: Run '$1' locally, commit the changes and push to your branch${C_RESET}\n"
|
||||
exit 1
|
||||
if [[ "$SHOULD_AUTO_COMMIT_CHANGES" == "true" && "${BUILDKITE_PULL_REQUEST:-}" ]]; then
|
||||
NEW_COMMIT_MESSAGE="[CI] Auto-commit changed files from '$1'"
|
||||
PREVIOUS_COMMIT_MESSAGE="$(git log -1 --pretty=%B)"
|
||||
|
||||
if [[ "$NEW_COMMIT_MESSAGE" == "$PREVIOUS_COMMIT_MESSAGE" ]]; then
|
||||
echo -e "\n${RED}ERROR: '$1' caused changes to the following files:${C_RESET}\n"
|
||||
echo -e "$GIT_CHANGES\n"
|
||||
echo -e "CI already attempted to commit these changes, but the file(s) seem to have changed again."
|
||||
echo -e "Please review and fix manually."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "'$1' caused changes to the following files:"
|
||||
echo "$GIT_CHANGES"
|
||||
echo ""
|
||||
echo "Auto-committing these changes now. A new build should start soon if successful."
|
||||
|
||||
git config --global user.name kibanamachine
|
||||
git config --global user.email '42973632+kibanamachine@users.noreply.github.com'
|
||||
gh pr checkout "${BUILDKITE_PULL_REQUEST}"
|
||||
git add -u -- . ':!.bazelrc'
|
||||
|
||||
git commit -m "$NEW_COMMIT_MESSAGE"
|
||||
git push
|
||||
exit 1
|
||||
else
|
||||
echo -e "\n${RED}ERROR: '$1' caused changes to the following files:${C_RESET}\n"
|
||||
echo -e "$GIT_CHANGES\n"
|
||||
echo -e "\n${YELLOW}TO FIX: Run '$1' locally, commit the changes and push to your branch${C_RESET}\n"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
@ -5,4 +5,6 @@ set -euo pipefail
|
|||
source .buildkite/scripts/common/util.sh
|
||||
|
||||
echo --- Check Bazel Packages Manifest
|
||||
node scripts/generate packages_build_manifest --validate
|
||||
node scripts/generate packages_build_manifest
|
||||
|
||||
check_for_changed_files 'node scripts/generate packages_build_manifest' true
|
||||
|
|
|
@ -7,4 +7,4 @@ source .buildkite/scripts/common/util.sh
|
|||
echo "--- Building kbn-pm distributable"
|
||||
yarn kbn run build -i @kbn/pm
|
||||
|
||||
verify_no_git_changes 'yarn kbn run build -i @kbn/pm'
|
||||
check_for_changed_files 'yarn kbn run build -i @kbn/pm' true
|
||||
|
|
|
@ -7,4 +7,4 @@ source .buildkite/scripts/common/util.sh
|
|||
echo "--- Building plugin list docs"
|
||||
node scripts/build_plugin_list_docs
|
||||
|
||||
verify_no_git_changes 'node scripts/build_plugin_list_docs'
|
||||
check_for_changed_files 'node scripts/build_plugin_list_docs' true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue