commands.yml 4.1 KB

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