2
0

test-react-ui.yaml 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. name: Test if React UI builds
  2. on:
  3. push:
  4. branches: ["main"]
  5. workflow_dispatch:
  6. jobs:
  7. build:
  8. runs-on: ubuntu-latest
  9. steps:
  10. - name: Checkout
  11. uses: actions/checkout@v4
  12. - name: Detect package manager
  13. id: detect-package-manager
  14. working-directory: react-ui
  15. run: |
  16. if [ -f "${{ github.workspace }}/react-ui/yarn.lock" ]; then
  17. echo "manager=yarn" >> $GITHUB_OUTPUT
  18. echo "command=install" >> $GITHUB_OUTPUT
  19. echo "runner=yarn" >> $GITHUB_OUTPUT
  20. exit 0
  21. elif [ -f "${{ github.workspace }}/react-ui/package.json" ]; then
  22. echo "manager=npm" >> $GITHUB_OUTPUT
  23. echo "command=ci" >> $GITHUB_OUTPUT
  24. echo "runner=npx --no-install" >> $GITHUB_OUTPUT
  25. exit 0
  26. else
  27. echo "Unable to determine package manager"
  28. exit 1
  29. fi
  30. - name: Setup Node
  31. uses: actions/setup-node@v3
  32. with:
  33. # working-directory: react-ui
  34. cache-dependency-path: "react-ui"
  35. node-version: "22"
  36. cache: ${{ steps.detect-package-manager.outputs.manager }}
  37. - name: Restore cache
  38. uses: actions/cache@v3
  39. with:
  40. path: |
  41. .next/cache
  42. # Generate a new cache whenever packages or source files change.
  43. key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
  44. # If source files changed but packages didn't, rebuild from a prior cache.
  45. restore-keys: |
  46. ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
  47. - name: Install dependencies
  48. working-directory: react-ui
  49. run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
  50. - name: Build with Next.js
  51. working-directory: react-ui
  52. run: ${{ steps.detect-package-manager.outputs.runner }} npm run build
  53. - name: Static HTML export with Next.js
  54. working-directory: react-ui
  55. run: ${{ steps.detect-package-manager.outputs.runner }} next export