validate-licenses.yml 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. name: Validate Plugin Licenses
  2. on:
  3. pull_request:
  4. paths:
  5. - 'plugins/**'
  6. push:
  7. branches: [main]
  8. paths:
  9. - 'plugins/**'
  10. permissions:
  11. contents: read
  12. jobs:
  13. validate-licenses:
  14. runs-on: ubuntu-latest
  15. steps:
  16. - uses: actions/checkout@v4
  17. - name: Check every plugin has an Apache 2.0 LICENSE file
  18. run: |
  19. set -euo pipefail
  20. missing=()
  21. wrong_content=()
  22. for plugin_dir in plugins/*/; do
  23. plugin="${plugin_dir%/}"
  24. if [[ ! -f "$plugin/LICENSE" ]]; then
  25. missing+=("$plugin")
  26. elif ! grep -q "Apache License" "$plugin/LICENSE" || \
  27. ! grep -q "Version 2.0" "$plugin/LICENSE"; then
  28. wrong_content+=("$plugin")
  29. fi
  30. done
  31. if [[ "${#missing[@]}" -gt 0 ]]; then
  32. echo "::error::The following plugins are missing a LICENSE file:"
  33. for p in "${missing[@]}"; do
  34. echo " - $p"
  35. done
  36. exit 1
  37. fi
  38. if [[ "${#wrong_content[@]}" -gt 0 ]]; then
  39. echo "::error::The following plugins have a LICENSE file that does not contain Apache 2.0 text:"
  40. for p in "${wrong_content[@]}"; do
  41. echo " - $p"
  42. done
  43. exit 1
  44. fi
  45. echo "All $(ls -d plugins/*/ | wc -l) plugins have an Apache 2.0 LICENSE file."