web.yml 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. name: Build Web
  2. on:
  3. push:
  4. branches:
  5. - master
  6. paths:
  7. - '**/modules/web/**'
  8. workflow_dispatch:
  9. env:
  10. UPSTREAM_REPOSITORY: gedoor/legado
  11. jobs:
  12. build:
  13. runs-on: ubuntu-latest
  14. steps:
  15. - name: Checkout
  16. uses: actions/checkout@v3
  17. - name: Install Node.js
  18. uses: actions/setup-node@v3
  19. with:
  20. node-version: 16
  21. - uses: pnpm/action-setup@v2
  22. name: Install pnpm
  23. id: pnpm-install
  24. with:
  25. version: 8
  26. run_install: false
  27. - name: Get pnpm store directory
  28. id: pnpm-cache
  29. shell: bash
  30. run: |
  31. echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
  32. - uses: actions/cache@v3
  33. name: Setup pnpm cache
  34. with:
  35. path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
  36. key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/web/package.json') }}
  37. restore-keys: |
  38. ${{ runner.os }}-pnpm-store-
  39. - name: Build and move files
  40. run: |
  41. rm -rf $GITHUB_WORKSPACE/app/src/main/assets/web/source
  42. rm -rf $GITHUB_WORKSPACE/app/src/main/assets/web/bookshelf
  43. rm -rf $GITHUB_WORKSPACE/app/src/main/assets/web/vue
  44. mkdir $GITHUB_WORKSPACE/app/src/main/assets/web/vue
  45. cd $GITHUB_WORKSPACE/modules/web
  46. pnpm i
  47. pnpm build
  48. mv -f ./dist/* $GITHUB_WORKSPACE/app/src/main/assets/web/vue/
  49. version="v$(date -d "8 hour" -u +3.%y.%m%d%H)"
  50. echo "APP_VER=$version" >> $GITHUB_ENV
  51. - name: push changes
  52. if: ${{ github.repository == env.UPSTREAM_REPOSITORY }}
  53. uses: stefanzweifel/git-auto-commit-action@v4.16.0
  54. with:
  55. commit_message: Bump web ${{ env.APP_VER}}
  56. file_pattern: app/src/main/assets/web/vue/