6 PREVIEW_CLOUDFLARE_API_TOKEN:
7 description: API token to upload a preview to Cloudflare Pages
9 PREVIEW_CLOUDFLARE_ACCOUNT_ID:
10 description: Account ID to upload a preview to Cloudflare Pages
19 url: https://preview.openttd.org/pr${{ github.event.pull_request.number }}/
21 runs-on: ubuntu-latest
23 # If you change this version, change the numbers in the cache step,
24 # .github/workflows/ci-emscripten.yml (2x) and os/emscripten/Dockerfile too.
25 image: emscripten/emsdk:3.1.57
29 uses: actions/checkout@v4
31 ref: ${{ github.event.pull_request.head.sha }}
35 git config --global --add safe.directory ${GITHUB_WORKSPACE}
36 git checkout -b pr${{ github.event.pull_request.number }}
38 - name: Update to modern GCC
41 apt-get install -y gcc-12 g++-12
42 update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 100
43 update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 100
46 uses: actions/cache@v4
48 path: /emsdk/upstream/emscripten/cache
49 # If you change this version, change the numbers in the image configuration step,
50 # .github/workflows/ci-emscripten.yml (2x) and os/emscripten/Dockerfile too.
51 key: 3.1.57-${{ runner.os }}
53 - name: Add liblzma support
55 cp ${GITHUB_WORKSPACE}/os/emscripten/ports/liblzma.py /emsdk/upstream/emscripten/tools/ports/contrib/
57 - name: Build (host tools)
63 cmake .. -DOPTION_TOOLS_ONLY=ON
67 echo "Running on $(nproc) cores"
71 - name: Install GCC problem matcher
72 uses: ammaraskar/gcc-problem-matcher@master
81 -DHOST_BINARY_DIR=../build-host \
82 -DCMAKE_BUILD_TYPE=Release \
87 echo "Running on $(nproc) cores"
88 cmake --build . -j $(nproc) --target openttd
91 - name: Prepare preview
95 cp build/openttd.data public/
96 cp build/openttd.html public/
97 cp build/openttd.js public/
98 cp build/openttd.wasm public/
100 # Ensure we use the latest version of npm; the one we get with current
101 # emscripten doesn't allow running "npx wrangler" as root.
102 # Current emscripten can't install npm>=10.0.0 because node is too old.
105 - name: Publish preview
106 uses: cloudflare/pages-action@v1
108 apiToken: ${{ secrets.PREVIEW_CLOUDFLARE_API_TOKEN }}
109 accountId: ${{ secrets.PREVIEW_CLOUDFLARE_ACCOUNT_ID }}
110 projectName: ${{ vars.PREVIEW_CLOUDFLARE_PROJECT_NAME }}
112 branch: pr${{ github.event.pull_request.number }}