sync-labels.yml 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
  23. - uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
  24. id: setup-node
  25. with:
  26. node-version-file: '.volta.json'
  27. - name: Install github-label-sync
  28. run: yarn global add github-label-sync@2.2.0
  29. - name: Run github-label-sync
  30. run: |
  31. github-label-sync \
  32. --access-token ${{ secrets.GITHUB_TOKEN }} \
  33. --labels .github/labels.yml \
  34. ${{ github.event_name == 'pull_request' && '--dry-run' || '' }} \
  35. ${{ github.repository }} \
  36. 2>&1 | tee sync-report.txt
  37. - name: Read sync output into variable
  38. uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
  39. if: github.event_name == 'pull_request'
  40. id: github-label-sync
  41. with:
  42. script: |
  43. const fs = require('fs');
  44. return fs.readFileSync('sync-report.txt','utf8').toString();
  45. result-encoding: string
  46. - name: Find previous dry-run comment
  47. uses: peter-evans/find-comment@a54c31d7fa095754bfef525c0c8e5e5674c4b4b1 # v2.4.0
  48. if: github.event_name == 'pull_request'
  49. id: fc
  50. with:
  51. issue-number: ${{ github.event.pull_request.number }}
  52. comment-author: 'github-actions[bot]'
  53. body-includes: '<!-- LABELS_UPDATE -->'
  54. - name: Add or update dry-run comment
  55. uses: peter-evans/create-or-update-comment@b95e16d2859ad843a14218d1028da5b2c4cbc4b4
  56. if: github.event_name == 'pull_request'
  57. with:
  58. issue-number: ${{ github.event.pull_request.number }}
  59. comment-id: ${{ steps.fc.outputs.comment-id }}
  60. edit-mode: replace
  61. body: >
  62. <!-- LABELS_UPDATE -->
  63. 🏷 The following changes will be made to the repository labels
  64. ```
  65. ${{ steps.github-label-sync.outputs.result }}
  66. ```