command-pull-3rdparty.yml 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
  2. # SPDX-License-Identifier: MIT
  3. name: Update 3rdparty command
  4. on:
  5. issue_comment:
  6. types: created
  7. permissions:
  8. contents: read
  9. jobs:
  10. rebase:
  11. runs-on: ubuntu-latest
  12. permissions:
  13. contents: none
  14. # On pull requests and if the comment starts with `/update-3rdparty`
  15. if: github.event.issue.pull_request != '' && startsWith(github.event.comment.body, '/update-3rdparty')
  16. steps:
  17. - name: Add reaction on start
  18. uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v3.0.1
  19. with:
  20. token: ${{ secrets.COMMAND_BOT_PAT }}
  21. repository: ${{ github.event.repository.full_name }}
  22. comment-id: ${{ github.event.comment.id }}
  23. reactions: '+1'
  24. - name: Disabled on forks
  25. if: ${{ github.event.pull_request.head.repo.full_name != github.repository }}
  26. run: |
  27. echo 'Can not execute /update-3rdparty on forks'
  28. exit 1
  29. - name: Init branch
  30. uses: xt0rted/pull-request-comment-branch@e8b8daa837e8ea7331c0003c9c316a64c6d8b0b1 # v1
  31. id: comment-branch
  32. - name: Checkout ${{ steps.comment-branch.outputs.head_ref }}
  33. uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
  34. with:
  35. fetch-depth: 0
  36. token: ${{ secrets.COMMAND_BOT_PAT }}
  37. ref: ${{ steps.comment-branch.outputs.head_ref }}
  38. - name: Setup git
  39. run: |
  40. git config --local user.email 'nextcloud-command@users.noreply.github.com'
  41. git config --local user.name 'nextcloud-command'
  42. - name: Pull 3rdparty
  43. run: git submodule foreach 'if [ "$sm_path" == "3rdparty" ]; then git pull origin '"'"'${{ github.event.issue.pull_request.base.ref }}'"'"'; fi'
  44. - name: Commit and push changes
  45. run: |
  46. git add 3rdparty
  47. git commit -s -m 'Update submodule 3rdparty to latest ${{ github.event.issue.pull_request.base.ref }}'
  48. git push
  49. - name: Add reaction on failure
  50. uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v3.0.1
  51. if: failure()
  52. with:
  53. token: ${{ secrets.COMMAND_BOT_PAT }}
  54. repository: ${{ github.event.repository.full_name }}
  55. comment-id: ${{ github.event.comment.id }}
  56. reactions: '-1'