25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

github-pull.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> <format-file>"
  6. exit 1
  7. fi
  8. # Assign variables
  9. GITHUB_REPOSITORY="$1"
  10. GITHUB_PULL_REQUEST="$2"
  11. FORMAT_FILE="$3"
  12. # Move to root of project
  13. cd "$GITHUB_WORKSPACE"
  14. # Determine files
  15. FORMAT_FILE="$( realpath "${FORMAT_FILE}" )"
  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 -o diff.txt "$DIFF_URL"
  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..."
  38. ./build/validate_links.py "$LINK_FILE"
  39. # Vebosity
  40. if [[ $? != 0 ]]; then
  41. echo "link validation failed!"
  42. exit 1
  43. else
  44. echo "link validation passed!"
  45. fi