Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

close-external-repo-sync-prs.yml 2.0 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
  1. name: Check for External Repo Sync PR
  2. on:
  3. pull_request:
  4. types:
  5. - opened
  6. - reopened
  7. branches:
  8. - main
  9. jobs:
  10. invalid-repo-sync-check:
  11. name: Close external Repo Sync PRs
  12. if: ${{ github.repository == 'github/docs' && github.ref == 'refs/heads/repo-sync' }}
  13. runs-on: ubuntu-latest
  14. steps:
  15. - uses: actions/github-script@626af12fe9a53dc2972b48385e7fe7dec79145c9
  16. with:
  17. github-token: ${{ secrets.DOCUBOT_FR_PROJECT_BOARD_WORKFLOWS_REPO_ORG_READ_SCOPES }}
  18. script: |
  19. const prCreator = context.payload.sender.login
  20. // If the PR creator is the expected account, stop now
  21. if (prCreator === 'Octomerger') {
  22. return
  23. }
  24. try {
  25. await github.teams.getMembershipForUserInOrg({
  26. org: 'github',
  27. team_slug: 'employees',
  28. username: prCreator
  29. })
  30. // If the PR creator is a GitHub employee, stop now
  31. return
  32. } catch (err) {
  33. // An error will be thrown if the user is not a GitHub employee.
  34. // That said, we still want to proceed anyway!
  35. }
  36. const pr = context.payload.pull_request
  37. const { owner, repo } = context.repo
  38. // Close the PR and add the invalid label
  39. await github.issues.update({
  40. owner: owner,
  41. repo: repo,
  42. issue_number: pr.number,
  43. labels: ['invalid'],
  44. state: 'closed'
  45. })
  46. // Comment on the PR
  47. await github.issues.createComment({
  48. owner: owner,
  49. repo: repo,
  50. issue_number: pr.number,
  51. body: "Please leave this `repo-sync` branch to the robots!\n\nI'm going to close this pull request now, but feel free to open a new issue or ask any questions in [discussions](https://github.com/github/docs/discussions)!"
  52. })
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...