1
0

action.yml 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. name: Deploy markdown.html
  2. description: Compress markdown.html and deploy to target directory
  3. author: 'PJ568'
  4. inputs:
  5. target-dir:
  6. description: Directory to deploy the minimized HTML file
  7. default: "."
  8. file-name:
  9. description: Name of the minimized HTML file
  10. default: "index.html"
  11. use-minified:
  12. description: Whether to use minified HTML file
  13. default: "true"
  14. use-all-in-one:
  15. description: Whether to use all-in-one HTML file
  16. default: "false"
  17. runs:
  18. using: "composite"
  19. steps:
  20. - name: Setup Rust
  21. uses: MatteoH2O1999/setup-rust@v1
  22. if: ${{ inputs.use-minified == 'true' || inputs.use-all-in-one == 'true' }}
  23. working-directory: ${{ github.action_path }}
  24. - name: Cache Rust dependencies
  25. if: ${{ inputs.use-minified == 'true' || inputs.use-all-in-one == 'true' }}
  26. uses: Swatinem/rust-cache@v2
  27. working-directory:
  28. with:
  29. workspaces: "${{ github.action_path }} -> target"
  30. cache-on-failure: "true"
  31. - name: Build project
  32. if: ${{ inputs.use-minified == 'true' || inputs.use-all-in-one == 'true' }}
  33. run: cargo build --release
  34. shell: bash
  35. working-directory: ${{ github.action_path }}
  36. - name: Generate minimized HTML
  37. if: ${{ inputs.use-minified == 'true' || inputs.use-all-in-one == 'true' }}
  38. run: cargo run --release -- index.html
  39. shell: bash
  40. working-directory: ${{ github.action_path }}
  41. - name: Deploy file
  42. run: |
  43. mkdir -p "${{ inputs.target-dir }}"
  44. USE_MINIFIED=""
  45. USE_ALL_IN_ONE=""
  46. if [ "${{ inputs.use-minified }}" = "true" ]; then
  47. USE_MINIFIED=".min"
  48. fi
  49. if [ "${{ inputs.use-all-in-one }}" = "true" ]; then
  50. USE_ALL_IN_ONE=".allinone"
  51. fi
  52. cp -uv index${USE_ALL_IN_ONE}${USE_MINIFIED}.html "${{ inputs.target-dir }}/${{ inputs.file-name }}"
  53. shell: bash
  54. working-directory: ${{ github.action_path }}
  55. branding:
  56. icon: 'book-open'
  57. color: 'green'