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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
  23. - uses: getsentry/action-setup-volta@c52be2ea13cfdc084edb806e81958c13e445941e # v1.2.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@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
  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@a54c31d7fa095754bfef525c0c8e5e5674c4b4b1 # v2.4.0
  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. ```