build.yml 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. name: Build
  2. on:
  3. push:
  4. branches:
  5. - main
  6. workflow_dispatch:
  7. env:
  8. UPSTREAM_REPOSITORY: gedoor/legado_web_source_editor
  9. jobs:
  10. build:
  11. runs-on: ubuntu-latest
  12. steps:
  13. - name: Checkout Project
  14. uses: actions/checkout@v3
  15. - uses: actions/cache@v3
  16. with:
  17. path: ~/.npm
  18. key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
  19. restore-keys: |
  20. ${{ runner.os }}-node-
  21. - name: Install Project
  22. run: |
  23. npm install
  24. - name: Format code
  25. if: ${{ github.repository == env.UPSTREAM_REPOSITORY }}
  26. run: |
  27. npm run-script lint
  28. - name: push changes
  29. if: ${{ github.repository == env.UPSTREAM_REPOSITORY }}
  30. uses: stefanzweifel/git-auto-commit-action@v4.16.0
  31. with:
  32. commit_message: 'style: format code'
  33. file_pattern: src
  34. - name: Build
  35. run: |
  36. npm run-script build
  37. - name: Set Env
  38. if: ${{ github.repository == env.UPSTREAM_REPOSITORY }}
  39. shell: bash
  40. run: |
  41. version="v$(date -d "8 hour" -u +3.%y.%m%d%H)"
  42. echo "APP_VER=$version" >> $GITHUB_ENV
  43. - name: Push changes to legado
  44. continue-on-error: true
  45. if: ${{ github.repository == env.UPSTREAM_REPOSITORY }}
  46. run: |
  47. git config --global user.name "github-actions[bot]"
  48. git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
  49. git clone "https://gedoor:${{ secrets.ACTIONS_TOKEN }}@github.com/gedoor/legado" --depth 1
  50. rm -rf legado/app/src/main/assets/web/source/*
  51. mv -f $GITHUB_WORKSPACE/dist/* legado/app/src/main/assets/web/source/
  52. cd legado
  53. git add -A
  54. git commit -m "web source editor: ${{ env.APP_VER }}"
  55. git push