You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

command-compile.yml 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. name: Compile Command
  2. on:
  3. issue_comment:
  4. types: [created]
  5. jobs:
  6. init:
  7. runs-on: ubuntu-latest
  8. # On pull requests and if the comment starts with `/compile`
  9. if: github.event.issue.pull_request != '' && startsWith(github.event.comment.body, '/compile')
  10. outputs:
  11. git_path: ${{ steps.git-path.outputs.path }}
  12. arg1: ${{ steps.command.outputs.arg1 }}
  13. arg2: ${{ steps.command.outputs.arg2 }}
  14. head_ref: ${{ steps.comment-branch.outputs.head_ref }}
  15. steps:
  16. - name: Check actor permission
  17. uses: skjnldsv/check-actor-permission@v2
  18. with:
  19. require: write
  20. - name: Add reaction on start
  21. uses: peter-evans/create-or-update-comment@v1
  22. with:
  23. token: ${{ secrets.COMMAND_BOT_PAT }}
  24. repository: ${{ github.event.repository.full_name }}
  25. comment-id: ${{ github.event.comment.id }}
  26. reaction-type: "+1"
  27. - name: Parse command
  28. uses: skjnldsv/parse-command-comment@master
  29. id: command
  30. # Init path depending on which command is run
  31. - name: Init path
  32. id: git-path
  33. run: |
  34. if ${{ startsWith(steps.command.outputs.arg1, '/') }}; then
  35. echo "::set-output name=path::${{ github.workspace }}${{steps.command.outputs.arg1}}"
  36. else
  37. echo "::set-output name=path::${{ github.workspace }}${{steps.command.outputs.arg2}}"
  38. fi
  39. - name: Init branch
  40. uses: xt0rted/pull-request-comment-branch@v1
  41. id: comment-branch
  42. process:
  43. runs-on: ubuntu-latest
  44. needs: init
  45. steps:
  46. - name: Checkout ${{ needs.init.outputs.head_ref }}
  47. uses: actions/checkout@v2
  48. with:
  49. token: ${{ secrets.COMMAND_BOT_PAT }}
  50. fetch-depth: 0
  51. ref: ${{ needs.init.outputs.head_ref }}
  52. - name: Setup git
  53. run: |
  54. git config --local user.email "nextcloud-command@users.noreply.github.com"
  55. git config --local user.name "nextcloud-command"
  56. - name: Read package.json node and npm engines version
  57. uses: skjnldsv/read-package-engines-version-actions@v1
  58. id: package-engines-versions
  59. with:
  60. fallbackNode: '^12'
  61. fallbackNpm: '^6'
  62. - name: Set up node ${{ steps.package-engines-versions.outputs.nodeVersion }}
  63. uses: actions/setup-node@v2
  64. with:
  65. node-version: ${{ steps.package-engines-versions.outputs.nodeVersion }}
  66. cache: npm
  67. - name: Set up npm ${{ steps.package-engines-versions.outputs.npmVersion }}
  68. run: npm i -g npm@"${{ steps.package-engines-versions.outputs.npmVersion }}"
  69. - name: Install dependencies & build
  70. run: |
  71. npm ci
  72. npm run build --if-present
  73. - name: Build css
  74. run: npm run sass
  75. - name: Build icons css
  76. run: npm run sass:icons
  77. - name: Commit and push default
  78. if: ${{ needs.init.outputs.arg1 != 'fixup' && needs.init.outputs.arg1 != 'amend' }}
  79. run: |
  80. git add ${{ needs.init.outputs.git_path }}
  81. git commit --signoff -m 'Compile assets'
  82. git push origin ${{ needs.init.outputs.head_ref }}
  83. - name: Commit and push fixup
  84. if: ${{ needs.init.outputs.arg1 == 'fixup' }}
  85. run: |
  86. git add ${{ needs.init.outputs.git_path }}
  87. git commit --fixup=HEAD --signoff
  88. git push origin ${{ needs.init.outputs.head_ref }}
  89. - name: Commit and push amend
  90. if: ${{ needs.init.outputs.arg1 == 'amend' }}
  91. run: |
  92. git add ${{ needs.init.outputs.git_path }}
  93. git commit --amend --no-edit --signoff
  94. git push --force origin ${{ needs.init.outputs.head_ref }}
  95. - name: Add reaction on failure
  96. uses: peter-evans/create-or-update-comment@v1
  97. if: failure()
  98. with:
  99. token: ${{ secrets.COMMAND_BOT_PAT }}
  100. repository: ${{ github.event.repository.full_name }}
  101. comment-id: ${{ github.event.comment.id }}
  102. reaction-type: "-1"