web.yml 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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: Install dependencies
  40. run: pnpm install
  41. - name: Build and move files
  42. run: |
  43. rm -rf $GITHUB_WORKSPACE/app/src/main/assets/web/source
  44. rm -rf $GITHUB_WORKSPACE/app/src/main/assets/web/bookshelf
  45. rm -rf $GITHUB_WORKSPACE/app/src/main/assets/web/vue
  46. mkdir $GITHUB_WORKSPACE/app/src/main/assets/web/vue
  47. cd $GITHUB_WORKSPACE/modules/web
  48. pnpm build
  49. mv -f ./dist/* $GITHUB_WORKSPACE/app/src/main/assets/web/vue/
  50. version="v$(date -d "8 hour" -u +3.%y.%m%d%H)"
  51. echo "APP_VER=$version" >> $GITHUB_ENV
  52. - name: push changes
  53. if: ${{ github.repository == env.UPSTREAM_REPOSITORY }}
  54. uses: stefanzweifel/git-auto-commit-action@v4.16.0
  55. with:
  56. commit_message: Bump web ${{ env.APP_VER}}
  57. file_pattern: app/src/main/assets/web/vue/