You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.4 KiB

  1. #!/bin/bash
  2. FORMAT_FILE=../README.md
  3. echo "running format validation..."
  4. ./validate_format.py $FORMAT_FILE
  5. if [[ $? != 0 ]]; then
  6. echo "format validation failed!"
  7. exit 1
  8. fi
  9. echo "format validation passed!"
  10. ./build.sh
  11. if [[ $? != 0 ]]; then
  12. echo "JSON build failed!"
  13. else
  14. echo "JSON build success!"
  15. fi
  16. if [ "$TRAVIS_BRANCH" == "master" ]
  17. then
  18. echo "Master build - deploying JSON"
  19. ./deploy.sh
  20. fi
  21. if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
  22. echo "running on $TRAVIS_BRANCH branch - skipping Pull Request logic"
  23. exit 0
  24. fi
  25. echo "running on Pull Request #$TRAVIS_PULL_REQUEST"
  26. DIFF_URL="https://patch-diff.githubusercontent.com/raw/toddmotto/public-apis/pull/$TRAVIS_PULL_REQUEST.diff"
  27. curl $DIFF_URL > diff.txt
  28. echo "------- BEGIN DIFF -------"
  29. cat diff.txt
  30. echo "-------- END DIFF --------"
  31. cat diff.txt | egrep "\+" > additions.txt
  32. echo "------ BEGIN ADDITIONS -----"
  33. cat additions.txt
  34. echo "------- END ADDITIONS ------"
  35. LINK_FILE=additions.txt
  36. echo "checking if /json was changed..."
  37. if egrep "\+{3}\s.\/json\/" diff.txt > json.txt; then
  38. echo "JSON files are auto-generated! Please do not update these files:"
  39. cat json.txt
  40. exit 1
  41. else
  42. echo "/json check passed!"
  43. rm json.txt
  44. fi
  45. echo "running link validation..."
  46. ./validate_links.py $LINK_FILE
  47. if [[ $? != 0 ]]; then
  48. echo "link validation failed!"
  49. exit 1
  50. else
  51. echo "link validation passed!"
  52. fi