handbook.yml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. name: "Handbook"
  2. on:
  3. workflow_dispatch: ~
  4. push:
  5. paths:
  6. - "src/handbook/**.tsx"
  7. branches:
  8. - "development"
  9. - "unstable"
  10. pull_request:
  11. paths:
  12. - "src/handbook/**.tsx"
  13. types:
  14. - opened
  15. - synchronize
  16. - reopened
  17. jobs:
  18. Lint-Code:
  19. runs-on: ubuntu-latest
  20. steps:
  21. - name: Checkout
  22. uses: actions/checkout@v3
  23. - name: Extract branch name
  24. shell: bash
  25. run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
  26. id: extract_branch
  27. - name: Setup Node
  28. uses: actions/setup-node@v2
  29. with:
  30. node-version: '17'
  31. - name: Cache node modules
  32. uses: actions/cache@v2
  33. with:
  34. path: |
  35. ~/.npm
  36. ~/.cache
  37. key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
  38. restore-keys: |
  39. ${{ runner.os }}-node-
  40. - name: Install dependencies
  41. working-directory: src/handbook
  42. run: npm install --force
  43. - name: Run linter
  44. working-directory: src/handbook
  45. run: npm run lint
  46. - run: git config --global user.name "github-actions"
  47. - run: git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
  48. - run: git stash
  49. - run: git checkout ${{ steps.extract_branch.outputs.branch }} && git pull
  50. - run: git stash pop || true
  51. - name: Commit changes
  52. if: ${{ github.event_name == 'push' }}
  53. run: git add -u && git commit -m "Lint Code [skip actions]" || true
  54. - name: Push changes
  55. if: ${{ github.event_name == 'push' }}
  56. run: git push --set-upstream --force origin ${{ steps.extract_branch.outputs.branch }}
  57. Build-Handbook:
  58. runs-on: ubuntu-latest
  59. steps:
  60. - name: Checkout
  61. uses: actions/checkout@v3
  62. - name: Setup Node
  63. uses: actions/setup-node@v2
  64. with:
  65. node-version: '17'
  66. - name: Cache node modules
  67. uses: actions/cache@v2
  68. with:
  69. path: |
  70. ~/.npm
  71. ~/.cache
  72. key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
  73. restore-keys: |
  74. ${{ runner.os }}-node-
  75. - name: Install dependencies
  76. working-directory: src/handbook
  77. run: npm install --force
  78. - name: Download Avatar Data
  79. uses: suisei-cn/actions-download-file@v1.4.0
  80. with:
  81. url: https://api.grasscutter.io/static/avatars.csv
  82. target: src/handbook/data/
  83. - name: Download Command Data
  84. uses: suisei-cn/actions-download-file@v1.4.0
  85. with:
  86. url: https://api.grasscutter.io/static/commands.json
  87. target: src/handbook/data/
  88. - name: Download Entity Data
  89. uses: suisei-cn/actions-download-file@v1.4.0
  90. with:
  91. url: https://api.grasscutter.io/static/entities.csv
  92. target: src/handbook/data/
  93. - name: Download Item Data
  94. uses: suisei-cn/actions-download-file@v1.4.0
  95. with:
  96. url: https://api.grasscutter.io/static/items.csv
  97. target: src/handbook/data/
  98. - name: Download Scene Data
  99. uses: suisei-cn/actions-download-file@v1.4.0
  100. with:
  101. url: https://api.grasscutter.io/static/scenes.csv
  102. target: src/handbook/data/
  103. - name: Download Quest Data
  104. uses: suisei-cn/actions-download-file@v1.4.0
  105. with:
  106. url: https://api.grasscutter.io/static/quests.csv
  107. target: src/handbook/data/
  108. - name: Download Main Quest Data
  109. uses: suisei-cn/actions-download-file@v1.4.0
  110. with:
  111. url: https://api.grasscutter.io/static/mainquests.csv
  112. target: src/handbook/data/
  113. - name: Build handbook
  114. working-directory: src/handbook
  115. run: npm run build
  116. - name: Upload build
  117. uses: actions/upload-artifact@v3
  118. with:
  119. name: Handbook
  120. path: src/handbook/dist/*.html