diff options
author | Stoabrogga <38475780+Stoabrogga@users.noreply.github.com> | 2019-02-25 11:30:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-25 11:30:43 +0100 |
commit | 845a3b65db5f18cac5b7171be35913a763c153e4 (patch) | |
tree | c019917e0ba1b6cc5536dcf4caa240a00f0a656b | |
parent | 15622225d642d9db207ebacf920d30c061aaa57f (diff) |
feat(CI): add commit hashes to the automatic SQL import (#1516)
-rw-r--r-- | .travis.yml | 4 | ||||
-rw-r--r-- | apps/db_pendings/import.sh | 9 |
2 files changed, 11 insertions, 2 deletions
diff --git a/.travis.yml b/.travis.yml index c3c6fd2e0e..a99c466243 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,12 +24,12 @@ before_install: - git config user.email "azerothcorebot@gmail.com" && git config user.name "AzerothCoreBot" - if [ "$TRAVIS_BUILD_ID" = "1" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ]; then cd bin/; fi # import pending sql - - if [ "$TRAVIS_BUILD_ID" = "1" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "master" ]; then bash acore-db-pendings; fi + - if [ "$TRAVIS_BUILD_ID" = "1" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "master" ]; then source acore-db-pendings; fi - if [ "$TRAVIS_BUILD_ID" = "1" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ]; then cd ..; fi # push changes to git if any - if [ "$TRAVIS_BUILD_ID" = "1" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ]; then git fetch --unshallow; fi - if [ "$TRAVIS_BUILD_ID" = "1" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ]; then git checkout $TRAVIS_BRANCH; fi - - if [ "$TRAVIS_BUILD_ID" = "1" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ] && [[ -n "$GITHUB_API_KEY" ]]; then git add -A . && git diff --cached --quiet || git commit -am "Import pending SQL update file" && git push https://$GITHUB_API_KEY@github.com/$TRAVIS_REPO_SLUG.git $TRAVIS_BRANCH; fi + - if [ "$TRAVIS_BUILD_ID" = "1" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ] && [[ -n "$GITHUB_API_KEY" ]]; then git add -A . && git diff --cached --quiet || git commit -am "Import pending SQL update file..." -m "Referenced commit(s):$COMMIT_HASH" && git push https://$GITHUB_API_KEY@github.com/$TRAVIS_REPO_SLUG.git $TRAVIS_BRANCH; fi # sync staging with master - if [ "$TRAVIS_BUILD_ID" = "1" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "master" ] && [[ -n "$GITHUB_API_KEY" ]]; then git fetch origin staging:staging && git checkout staging && git merge --no-edit master && git push https://$GITHUB_API_KEY@github.com/$TRAVIS_REPO_SLUG.git staging; git checkout master; fi - source ./apps/ci/ci-before_install.sh diff --git a/apps/db_pendings/import.sh b/apps/db_pendings/import.sh index ebbff1bbca..8879482fc2 100644 --- a/apps/db_pendings/import.sh +++ b/apps/db_pendings/import.sh @@ -6,6 +6,8 @@ source "$CURRENT_PATH/../bash_shared/includes.sh" UPDATES_PATH="$AC_PATH_ROOT/data/sql/updates/" +COMMIT_HASH= + function import() { db=$1 folder="db_"$db @@ -97,6 +99,13 @@ function import() { echo "DROP PROCEDURE IF EXISTS \`updateDb\`;" >> "$newFile"; fi; + currentHash="$(git log --diff-filter=A "$entry" | grep "^commit " | sed -e 's/commit //')" + + if [[ "$COMMIT_HASH" != *"$currentHash"* ]] + then + COMMIT_HASH="$COMMIT_HASH $currentHash" + fi + rm $entry; oldDate=$dateToday |