non-maintainer-dependency-change.yml 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. name: Check for Non-Maintainer Dependency Change
  2. on:
  3. pull_request_target:
  4. paths:
  5. - 'yarn.lock'
  6. - 'spec/yarn.lock'
  7. permissions: {}
  8. jobs:
  9. check-for-non-maintainer-dependency-change:
  10. name: Check for non-maintainer dependency change
  11. if: ${{ !contains(fromJSON('["MEMBER", "OWNER"]'), github.event.pull_request.author_association) && github.event.pull_request.user.type != 'Bot' && !github.event.pull_request.draft }}
  12. permissions:
  13. contents: read
  14. pull-requests: write
  15. runs-on: ubuntu-latest
  16. steps:
  17. - name: Check for existing review
  18. id: check-for-review
  19. env:
  20. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  21. PR_URL: ${{ github.event.pull_request.html_url }}
  22. run: |
  23. set -eo pipefail
  24. REVIEW_COUNT=$(gh pr view $PR_URL --json reviews | jq '[ .reviews[] | select(.author.login == "github-actions") | select(.body | startswith("<!-- no-dependency-change -->")) ] | length')
  25. if [[ $REVIEW_COUNT -eq 0 ]]; then
  26. echo "SHOULD_REVIEW=1" >> "$GITHUB_OUTPUT"
  27. fi
  28. - name: Request changes
  29. if: ${{ steps.check-for-review.outputs.SHOULD_REVIEW }}
  30. env:
  31. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  32. PR_URL: ${{ github.event.pull_request.html_url }}
  33. run: |
  34. printf "<!-- no-dependency-change -->\n\nHello @${{ github.event.pull_request.user.login }}! It looks like this pull request touches one of our dependency files, and per [our contribution policy](https://github.com/electron/electron/blob/main/CONTRIBUTING.md#dependencies-upgrades-policy) we do not accept these types of changes in PRs." | gh pr review $PR_URL -r --body-file=-