commands.yml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. name: Commands
  2. on:
  3. issue_comment:
  4. types:
  5. - created
  6. - edited
  7. pull_request_target:
  8. types:
  9. - labeled
  10. - synchronize
  11. permissions: {}
  12. jobs:
  13. rebase:
  14. name: Rebase
  15. if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '@jellyfin-bot rebase') && github.event.comment.author_association == 'MEMBER'
  16. runs-on: ubuntu-latest
  17. steps:
  18. - name: Notify as seen
  19. uses: peter-evans/create-or-update-comment@c6c9a1a66007646a28c153e2a8580a5bad27bcfa # v3.0.2
  20. with:
  21. token: ${{ secrets.JF_BOT_TOKEN }}
  22. comment-id: ${{ github.event.comment.id }}
  23. reactions: '+1'
  24. - name: Checkout the latest code
  25. uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
  26. with:
  27. token: ${{ secrets.JF_BOT_TOKEN }}
  28. fetch-depth: 0
  29. - name: Automatic Rebase
  30. uses: cirrus-actions/rebase@b87d48154a87a85666003575337e27b8cd65f691 # 1.8
  31. env:
  32. GITHUB_TOKEN: ${{ secrets.JF_BOT_TOKEN }}
  33. check-backport:
  34. permissions:
  35. contents: read
  36. name: Check Backport
  37. if: ${{ ( github.event.issue.pull_request && contains(github.event.comment.body, '@jellyfin-bot check backport') ) || github.event.label.name == 'stable backport' || contains(github.event.pull_request.labels.*.name, 'stable backport' ) }}
  38. runs-on: ubuntu-latest
  39. steps:
  40. - name: Notify as seen
  41. uses: peter-evans/create-or-update-comment@c6c9a1a66007646a28c153e2a8580a5bad27bcfa # v3.0.2
  42. if: ${{ github.event.comment != null }}
  43. with:
  44. token: ${{ secrets.JF_BOT_TOKEN }}
  45. comment-id: ${{ github.event.comment.id }}
  46. reactions: eyes
  47. - name: Checkout the latest code
  48. uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
  49. with:
  50. token: ${{ secrets.JF_BOT_TOKEN }}
  51. fetch-depth: 0
  52. - name: Notify as running
  53. id: comment_running
  54. uses: peter-evans/create-or-update-comment@c6c9a1a66007646a28c153e2a8580a5bad27bcfa # v3.0.2
  55. if: ${{ github.event.comment != null }}
  56. with:
  57. token: ${{ secrets.JF_BOT_TOKEN }}
  58. issue-number: ${{ github.event.issue.number }}
  59. body: |
  60. Running backport tests...
  61. - name: Perform test backport
  62. id: run_tests
  63. run: |
  64. set +o errexit
  65. git config --global user.name "Jellyfin Bot"
  66. git config --global user.email "team@jellyfin.org"
  67. CURRENT_BRANCH="origin/${GITHUB_HEAD_REF}"
  68. git checkout master
  69. git merge --no-ff ${CURRENT_BRANCH}
  70. MERGE_COMMIT_HASH=$( git log -q -1 | head -1 | awk '{ print $2 }' )
  71. git fetch --all
  72. CURRENT_STABLE=$( git branch -r | grep 'origin/release' | sort -rV | head -1 | awk -F '/' '{ print $NF }' )
  73. stable_branch="Current stable release branch: ${CURRENT_STABLE}"
  74. echo ${stable_branch}
  75. echo ::set-output name=branch::${stable_branch}
  76. git checkout -t origin/${CURRENT_STABLE} -b ${CURRENT_STABLE}
  77. git cherry-pick -sx -m1 ${MERGE_COMMIT_HASH} &>output.txt
  78. retcode=$?
  79. cat output.txt | grep -v 'hint:'
  80. output="$( grep -v 'hint:' output.txt )"
  81. output="${output//'%'/'%25'}"
  82. output="${output//$'\n'/'%0A'}"
  83. output="${output//$'\r'/'%0D'}"
  84. echo ::set-output name=output::$output
  85. exit ${retcode}
  86. - name: Notify with result success
  87. uses: peter-evans/create-or-update-comment@c6c9a1a66007646a28c153e2a8580a5bad27bcfa # v3.0.2
  88. if: ${{ github.event.comment != null && success() }}
  89. with:
  90. token: ${{ secrets.JF_BOT_TOKEN }}
  91. comment-id: ${{ steps.comment_running.outputs.comment-id }}
  92. body: |
  93. ${{ steps.run_tests.outputs.branch }}
  94. Output from `git cherry-pick`:
  95. ---
  96. ${{ steps.run_tests.outputs.output }}
  97. reactions: hooray
  98. - name: Notify with result failure
  99. uses: peter-evans/create-or-update-comment@c6c9a1a66007646a28c153e2a8580a5bad27bcfa # v3.0.2
  100. if: ${{ github.event.comment != null && failure() }}
  101. with:
  102. token: ${{ secrets.JF_BOT_TOKEN }}
  103. comment-id: ${{ steps.comment_running.outputs.comment-id }}
  104. body: |
  105. ${{ steps.run_tests.outputs.branch }}
  106. Output from `git cherry-pick`:
  107. ---
  108. ${{ steps.run_tests.outputs.output }}
  109. reactions: confused