-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from SoInteractive/feature_travis
travis
- Loading branch information
Showing
3 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
sudo: required | ||
language: python | ||
services: | ||
- docker | ||
install: | ||
- pip install ansible==2.3.2 molecule==1.25.0 docker git-semver | ||
script: | ||
- if [ -f requirements.yml ]; then ansible-galaxy install -r requirements.yml -p .molecule/roles/. ; fi | ||
- molecule test | ||
deploy: | ||
provider: script | ||
skip_cleanup: true | ||
script: | ||
- ./.travis/generatetag.sh | ||
on: | ||
branch: master | ||
#do not start when tag is added | ||
branches: | ||
only: | ||
- master | ||
tags: | ||
except: | ||
- /^\d+\.\d+\.\d+$/ | ||
notifications: | ||
webhooks: https://galaxy.ansible.com/api/v1/notifications/ | ||
after_script: | ||
- ./.travis/notification.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
git config --global user.email "[email protected]" | ||
git config --global user.name "soi-bot" | ||
GIT_TAG=$([[ "$TRAVIS_COMMIT_MESSAGE" =~ ("Merge pull request".*/feature.*) ]] && git semver --next-minor || git semver --next-patch ) | ||
echo $GIT_TAG | ||
git tag $GIT_TAG -a -m "Generated tag from TravisCI for build $TRAVIS_BUILD_NUMBER" | ||
GIT_URL=$(git config --get remote.origin.url) | ||
GIT_URL=${GIT_URL#*//} | ||
|
||
git push https://${GH_TOKEN}:@${GIT_URL} --tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
function success { | ||
GIT_TAG=$(git semver) | ||
echo $GIT_TAG | ||
if [ "$TRAVIS_PULL_REQUEST" != "false" ] | ||
then | ||
MESSAGE="Travis [build no. ${TRAVIS_BUILD_NUMBER}](travis-ci.org/${TRAVIS_REPO_SLUG}/builds/${TRAVIS_BUILD_ID}) has finished successfully. Pull request no. ${TRAVIS_PULL_REQUEST} opened by ${GIT_COMMITER} can be found [here](https://github.com/${TRAVIS_REPO_SLUG}/pull/${TRAVIS_PULL_REQUEST})." | ||
else | ||
MESSAGE="Travis [build no. ${TRAVIS_BUILD_NUMBER}](travis-ci.org/${TRAVIS_REPO_SLUG}/builds/${TRAVIS_BUILD_ID}) has finished successfully. Tag [${GIT_TAG}](https://github.com/${TRAVIS_REPO_SLUG}/releases/tag/${GIT_TAG}) was pushed to master by ${GIT_COMMITER}." | ||
fi | ||
echo $MESSAGE | ||
} | ||
|
||
function failure { | ||
if [ "$TRAVIS_PULL_REQUEST" != "false" ] | ||
then | ||
MESSAGE="Travis [build no. ${TRAVIS_BUILD_NUMBER}](travis-ci.org/${TRAVIS_REPO_SLUG}/builds/${TRAVIS_BUILD_ID}) has failed. Pull request no. ${TRAVIS_PULL_REQUEST} opened by ${GIT_COMMITER} can be found [here](https://github.com/${TRAVIS_REPO_SLUG}/pull/${TRAVIS_PULL_REQUEST})." | ||
else | ||
MESSAGE="Travis [build no. ${TRAVIS_BUILD_NUMBER}](travis-ci.org/${TRAVIS_REPO_SLUG}/builds/${TRAVIS_BUILD_ID}) has failed. Please check for problems on branch [master](https://github.com/${TRAVIS_REPO_SLUG}/tree/master) which was pushed by ${GIT_COMMITER} on repo [${TRAVIS_REPO_SLUG}](https://github.com/${TRAVIS_REPO_SLUG})." | ||
fi | ||
} | ||
|
||
if [ -z "$MM_WEBHOOK" ] | ||
then | ||
echo "MM_WEBHOOK variable is not set!" | ||
exit 0 | ||
fi | ||
|
||
GIT_COMMITER=$(git show -s --pretty=%an) | ||
echo $GIT_COMMITER | ||
if [ "$TRAVIS_TEST_RESULT" == "0" ] | ||
then | ||
success | ||
COLOR="#00FF00" | ||
else | ||
failure | ||
COLOR="#FF0000" | ||
fi | ||
|
||
curl -X POST --data-urlencode "payload={\"username\": \"soi\", \"attachments\": [{ \"color\": \"$COLOR\", \"text\": \"$MESSAGE\" }], \"icon_url\": \"https://maxcdn.icons8.com/office/PNG/512/Programming/bot_80-512.png\"}" "${MM_WEBHOOK}" |