export_html5.yml.disabled 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. name: Export projects to HTML5 and deploy to GitHub Pages
  2. on:
  3. push:
  4. branches:
  5. - master
  6. env:
  7. GODOT_VERSION: 3.3.3
  8. jobs:
  9. export-html5:
  10. name: Export projects to HTML5 and deploy to GitHub Pages
  11. runs-on: ubuntu-20.04
  12. container:
  13. image: barichello/godot-ci:3.3.3
  14. steps:
  15. - name: Checkout
  16. uses: actions/checkout@v3
  17. - name: Setup
  18. run: |
  19. mkdir -p ~/.local/share/godot/templates/
  20. mv /root/.local/share/godot/templates/$GODOT_VERSION.stable ~/.local/share/godot/templates/$GODOT_VERSION.stable
  21. - name: Export projects to HTML5
  22. run: |
  23. apt-get update -qq && apt-get install -qqq imagemagick
  24. # Don't export Mono demos (not supported yet), demos that can't be run in HTML5
  25. # since they're platform-specific or demos that are currently broken in HTML5.
  26. # Remember to update `.github/dist/footer.html` when updating the list of excluded demos.
  27. rm -rf \
  28. 2d/hdr/ \
  29. 3d/global_illumination/ \
  30. 3d/voxel/ \
  31. audio/device_changer/ \
  32. loading/background_load/ \
  33. loading/multiple_threads_loading/ \
  34. loading/threads/ \
  35. misc/matrix_transform/ \
  36. mobile/android_iap/ \
  37. mobile/sensors/ \
  38. mono/ \
  39. networking/ \
  40. plugins/
  41. for panorama in 3d/material_testers/backgrounds/*.hdr; do
  42. # Decrease the resolution to get below the 20 MB per-file limit.
  43. # Otherwise, the website can't be deployed as files larger than 20 MB
  44. # can't be pushed to GitHub anymore.
  45. mogrify -resize 75% "$panorama"
  46. done
  47. BASEDIR="$PWD"
  48. # Use absolute paths so that we can `cd` without having to go back to the parent directory manually.
  49. for demo in */*/; do
  50. echo ""
  51. echo "================================"
  52. echo "Exporting demo $demo..."
  53. echo "================================"
  54. mkdir -p "$BASEDIR/.github/dist/$demo"
  55. cd "$BASEDIR/$demo"
  56. # Copy an export template preset file configured for HTML5 exporting.
  57. # This way, we don't have to commit `export_presets.cfg` for each project.
  58. cp "$BASEDIR/.github/dist/export_presets.cfg" .
  59. godot --export "HTML5" "$BASEDIR/.github/dist/$demo/index.html"
  60. # Replace the WASM file with a symbolic link to avoid duplicating files in the pushed branch.
  61. # (WASM files are identical across projects, but not PCK or HTML files.)
  62. mv -f "$BASEDIR/.github/dist/$demo/index.wasm" "$BASEDIR/.github/dist/index.wasm"
  63. # The symlink must be relative as it needs to point to a file within the pushed repository.
  64. ln -s "../../index.wasm" "$BASEDIR/.github/dist/$demo/index.wasm"
  65. # Append the demo to the list of demos for the website.
  66. PROJECT_NAME=$(cat project.godot | grep "config/name" | cut -d '"' -f 2 | tr -d "\n")
  67. echo "<li><a href='$demo'><img width="64" height="64" src="$demo/favicon.png" alt=""><p>$PROJECT_NAME</p></a></li>" >> "$BASEDIR/.github/dist/demos.html"
  68. done
  69. cat "$BASEDIR/.github/dist/header.html" "$BASEDIR/.github/dist/demos.html" "$BASEDIR/.github/dist/footer.html" > "$BASEDIR/.github/dist/index.html"
  70. # Clean up files that don't need to be deployed.
  71. rm -f "$BASEDIR/.github/dist/header.html" "$BASEDIR/.github/dist/demos.html" "$BASEDIR/.github/dist/footer.html" "$BASEDIR/.github/dist/export_presets.cfg"
  72. # Installing rsync is needed in order to deploy to GitHub Pages. Without it, the build will fail.
  73. - name: Install rsync 📚
  74. run: |
  75. apt-get update -qq && apt-get install -qqq rsync
  76. - name: Deploy to GitHub Pages 🚀
  77. uses: JamesIves/github-pages-deploy-action@releases/v3
  78. with:
  79. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  80. # The branch the action should deploy to.
  81. BRANCH: gh-pages
  82. # The folder the action should deploy.
  83. FOLDER: .github/dist
  84. # Artifacts are large; don't keep the branch's history.
  85. SINGLE_COMMIT: true