lib.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/usr/bin/env bash
  2. #
  3. # Nextcloud Android Library is available under MIT license
  4. #
  5. # @author Álvaro Brey Vilas
  6. # Copyright (C) 2022 Álvaro Brey Vilas
  7. # Copyright (C) 2022 Nextcloud GmbH
  8. #
  9. # Permission is hereby granted, free of charge, to any person obtaining a copy
  10. # of this software and associated documentation files (the "Software"), to deal
  11. # in the Software without restriction, including without limitation the rights
  12. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. # copies of the Software, and to permit persons to whom the Software is
  14. # furnished to do so, subject to the following conditions:
  15. #
  16. # The above copyright notice and this permission notice shall be included in
  17. # all copies or substantial portions of the Software.
  18. #
  19. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20. # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  21. # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22. # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  23. # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  24. # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  25. # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  26. # THE SOFTWARE.
  27. #
  28. ## This file is intended to be sourced by other scripts
  29. function err() {
  30. echo >&2 "$@"
  31. }
  32. function curl_gh() {
  33. if [[ -n "$GITHUB_TOKEN" ]]
  34. then
  35. curl \
  36. --silent \
  37. --header "Authorization: token $GITHUB_TOKEN" \
  38. "$@"
  39. else
  40. err "WARNING: No GITHUB_TOKEN found. Skipping API call"
  41. fi
  42. }