sync-labels.yml 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. name: meta(labels)
  2. on:
  3. pull_request:
  4. paths:
  5. - .github/labels.yml
  6. push:
  7. branches:
  8. - master
  9. paths:
  10. - .github/labels.yml
  11. # hack for https://github.com/actions/cache/issues/810#issuecomment-1222550359
  12. env:
  13. SEGMENT_DOWNLOAD_TIMEOUT_MINS: 3
  14. jobs:
  15. sync:
  16. name: syncs repository labels
  17. runs-on: ubuntu-latest
  18. permissions:
  19. issues: write
  20. pull-requests: write
  21. steps:
  22. - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
  23. - uses: getsentry/action-setup-volta@54775a59c41065f54ecc76d1dd5f2cdc7a1550cb # v1.1.0
  24. - name: Install github-label-sync
  25. run: yarn global add github-label-sync@2.2.0
  26. - name: Run github-label-sync
  27. run: |
  28. github-label-sync \
  29. --access-token ${{ secrets.GITHUB_TOKEN }} \
  30. --labels .github/labels.yml \
  31. ${{ github.event_name == 'pull_request' && '--dry-run' || '' }} \
  32. ${{ github.repository }} \
  33. 2>&1 | tee sync-report.txt
  34. - name: Read sync output into variable
  35. uses: actions/github-script@d556feaca394842dc55e4734bf3bb9f685482fa0 # v6.3.3
  36. if: github.event_name == 'pull_request'
  37. id: github-label-sync
  38. with:
  39. script: |
  40. const fs = require('fs');
  41. return fs.readFileSync('sync-report.txt','utf8').toString();
  42. result-encoding: string
  43. - name: Find previous dry-run comment
  44. uses: peter-evans/find-comment@1769778a0c5bd330272d749d12c036d65e70d39d
  45. if: github.event_name == 'pull_request'
  46. id: fc
  47. with:
  48. issue-number: ${{ github.event.pull_request.number }}
  49. comment-author: 'github-actions[bot]'
  50. body-includes: '<!-- LABELS_UPDATE -->'
  51. - name: Add or update dry-run comment
  52. uses: peter-evans/create-or-update-comment@b95e16d2859ad843a14218d1028da5b2c4cbc4b4
  53. if: github.event_name == 'pull_request'
  54. with:
  55. issue-number: ${{ github.event.pull_request.number }}
  56. comment-id: ${{ steps.fc.outputs.comment-id }}
  57. edit-mode: replace
  58. body: >
  59. <!-- LABELS_UPDATE -->
  60. 🏷 The following changes will be made to the repository labels
  61. ```
  62. ${{ steps.github-label-sync.outputs.result }}
  63. ```