sync-labels.yml 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. jobs:
  12. sync:
  13. name: syncs repository labels
  14. runs-on: ubuntu-latest
  15. permissions:
  16. issues: write
  17. pull-requests: write
  18. steps:
  19. - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3
  20. - uses: ./.github/actions/setup-volta
  21. - name: Install github-label-sync
  22. run: yarn global add github-label-sync@2.2.0
  23. - name: Run github-label-sync
  24. run: |
  25. github-label-sync \
  26. --access-token ${{ secrets.GITHUB_TOKEN }} \
  27. --labels .github/labels.yml \
  28. ${{ github.event_name == 'pull_request' && '--dry-run' || '' }} \
  29. ${{ github.repository }} \
  30. 2>&1 | tee sync-report.txt
  31. - name: Read sync output into variable
  32. uses: actions/github-script@deb7ae927cc19ae3a8b57293dd5cd2f16171e1e2 # v4
  33. if: github.event_name == 'pull_request'
  34. id: github-label-sync
  35. with:
  36. script: |
  37. const fs = require('fs');
  38. return fs.readFileSync('sync-report.txt','utf8').toString();
  39. result-encoding: string
  40. - name: Find previous dry-run comment
  41. uses: peter-evans/find-comment@1769778a0c5bd330272d749d12c036d65e70d39d
  42. if: github.event_name == 'pull_request'
  43. id: fc
  44. with:
  45. issue-number: ${{ github.event.pull_request.number }}
  46. comment-author: 'github-actions[bot]'
  47. body-includes: '<!-- LABELS_UPDATE -->'
  48. - name: Add or update dry-run comment
  49. uses: peter-evans/create-or-update-comment@b95e16d2859ad843a14218d1028da5b2c4cbc4b4
  50. if: github.event_name == 'pull_request'
  51. with:
  52. issue-number: ${{ github.event.pull_request.number }}
  53. comment-id: ${{ steps.fc.outputs.comment-id }}
  54. edit-mode: replace
  55. body: >
  56. <!-- LABELS_UPDATE -->
  57. 🏷 The following changes will be made to the repository labels
  58. ```
  59. ${{ steps.github-label-sync.outputs.result }}
  60. ```