Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

github_pull_request.sh 1.3 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/usr/bin/env bash
  2. set -e
  3. # Argument validation
  4. if [ $# -ne 3 ]; then
  5. echo "Usage: $0 <github-repo> <pull-number> <filename>"
  6. exit 1
  7. fi
  8. # Assign variables
  9. GITHUB_REPOSITORY="$1"
  10. GITHUB_PULL_REQUEST="$2"
  11. FILENAME="$3"
  12. # Move to root of project
  13. cd "$GITHUB_WORKSPACE"
  14. # Determine files
  15. FILENAME="$( realpath "${FILENAME}" )"
  16. # Skip if build number could not be determined
  17. if [ -z "$GITHUB_REPOSITORY" -o -z "$GITHUB_PULL_REQUEST" ]; then
  18. echo "No pull request and/or repository is provided"
  19. exit 1
  20. fi
  21. # Pull changes on PR
  22. echo "running on Pull Request #$GITHUB_PULL_REQUEST"
  23. # Trick the URL validator python script into not seeing this as a URL
  24. DUMMY_SCHEME="https"
  25. DIFF_URL="$DUMMY_SCHEME://patch-diff.githubusercontent.com/raw/$GITHUB_REPOSITORY/pull/$GITHUB_PULL_REQUEST.diff"
  26. curl -L "$DIFF_URL" -o diff.txt
  27. # Construct diff
  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. # Validate links
  37. echo "Running link validation on additions..."
  38. python scripts/validate/links.py "$LINK_FILE"
  39. # Vebosity
  40. if [[ $? != 0 ]]; then
  41. echo "link validation failed on additions!"
  42. exit 1
  43. else
  44. echo "link validation passed on additions!"
  45. fi