| 1 | # Website Build and Deployment |
| 2 | |
| 3 | This document describes the end-to-end deployment strategy for the fheroes2 site deployment. |
| 4 | We target Github Pages for hosting and leverage GitHub Actions for automation. |
| 5 | |
| 6 | ## Functionality |
| 7 | |
| 8 | * Builds the documentation site for the fheroes2 project |
| 9 | * Deploys the site, along with WebAssembly build, to Github Pages on push. |
| 10 | * Allows end users to view the documentation via the web. |
| 11 | * Allows end users to click a link and launch the game via the web. |
| 12 | |
| 13 | ## Build and Deployment Diagram |
| 14 | |
| 15 | ```mermaid |
| 16 | sequenceDiagram |
| 17 | actor EndUser |
| 18 | actor Engineer |
| 19 | participant GitHubRepo |
| 20 | participant PushAction |
| 21 | participant MakeAction |
| 22 | participant GitHubReleases |
| 23 | participant PagesAction |
| 24 | participant GitHubPages |
| 25 | |
| 26 | Engineer->>GitHubRepo: Pushes change to master |
| 27 | GitHubRepo->>PushAction: Triggers workflow |
| 28 | PushAction->>MakeAction: Calls workflow |
| 29 | MakeAction->>GitHubReleases: Uploads release artifacts |
| 30 | PushAction->>PagesAction: Triggers workflow |
| 31 | PagesAction->>GitHubReleases: Downloads latest release |
| 32 | PagesAction->>GitHubPages: Deploys site |
| 33 | EndUser->>GitHubPages: Plays game via browser |
| 34 | ``` |
| 35 | |
| 36 | ## Deployment Pipeline Overview |
| 37 | |
| 38 | ### Trigger |
| 39 | |
| 40 | * Deployment is triggered **when a new Git commit is pushed**. |
| 41 | * A GitHub Action workflow waits for the completion of the build-and-release process (`make.yml` workflow). |
| 42 | |
| 43 | ### Build Process (Upstream) |
| 44 | |
| 45 | * Compiles the FHeroes2 WebAssembly bundle using Emscripten. |
| 46 | * Packages assets and build artifacts into a ZIP file. |
| 47 | * Publishes the ZIP as a GitHub Release asset using `ncipollo/release-action`. |
| 48 | |
| 49 | ### Deploy Process (Downstream) |
| 50 | |
| 51 | * Listens for completion of the upstream `Make` workflow. |
| 52 | * Pulls the latest GitHub Release and extracts the ZIP bundle. |
| 53 | * Builds and Deploys the Github Pages with the bundle. |
| 54 | |
| 55 | ## GitHub Workflows Summary |
| 56 | |
| 57 | ### make.yml |
| 58 | |
| 59 | * Triggered on `push` to branch |
| 60 | * Builds the application |
| 61 | * Publishes release assets |
| 62 | |
| 63 | ### pages.yml |
| 64 | |
| 65 | * Triggered on completion of `make.yml` |
| 66 | * Builds Jekyll site |
| 67 | * Downloads release |
| 68 | * Deploys to Github Pages |
| 69 | |
| 70 | ## Future Considerations |
| 71 | |
| 72 | * Hook up a custom domain if needed |
| 73 | * Allow better developer experience around pages/emscripten process for local builds |