14 # If you change this version, change the number in the cache step too.
15 image: emscripten/emsdk:2.0.10
16 # uid=1001(runner) gid=121(docker)
20 - name: Update deployment status to in progress
21 uses: octokit/request-action@v2.x
23 route: POST /repos/{owner}/{repo}/deployments/{deployment_id}/statuses
28 owner: ${{ github.event.repository.owner.login }}
29 repo: ${{ github.event.repository.name }}
30 deployment_id: ${{ github.event.client_payload.deployment_id }}
33 GITHUB_TOKEN: ${{ secrets.PREVIEW_GITHUB_TOKEN }}
36 uses: actions/checkout@v2
38 ref: ${{ github.event.client_payload.sha }}
42 name=$(echo "${{ github.event.client_payload.folder }}")
43 git checkout -b ${name}
46 uses: actions/cache@v2
48 path: /emsdk/upstream/emscripten/cache
49 key: 2.0.10-${{ runner.os }}
51 - name: Build (host tools)
57 cmake .. -DOPTION_TOOLS_ONLY=ON
61 echo "Running on $(nproc) cores"
65 - name: Install GCC problem matcher
66 uses: ammaraskar/gcc-problem-matcher@master
75 -DHOST_BINARY_DIR=../build-host \
76 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
81 echo "Running on $(nproc) cores"
82 emmake make -j$(nproc)
85 - name: Publish preview
87 # setuptools is missing in this Docker image, which breaks installing
88 # awscli. So we need to do this in two steps to recover sanity.
89 pip3 install setuptools
92 ~/.local/bin/aws s3 cp --only-show-errors build/openttd.data s3://${{ secrets.PREVIEW_S3_BUCKET }}/${{ github.event.client_payload.folder }}/
93 ~/.local/bin/aws s3 cp --only-show-errors build/openttd.html s3://${{ secrets.PREVIEW_S3_BUCKET }}/${{ github.event.client_payload.folder }}/
94 ~/.local/bin/aws s3 cp --only-show-errors build/openttd.js s3://${{ secrets.PREVIEW_S3_BUCKET }}/${{ github.event.client_payload.folder }}/
95 ~/.local/bin/aws s3 cp --only-show-errors build/openttd.wasm s3://${{ secrets.PREVIEW_S3_BUCKET }}/${{ github.event.client_payload.folder }}/
97 # Invalidate the cache of the CloudFront distribution
98 ~/.local/bin/aws cloudfront create-invalidation --distribution-id ${{ secrets.PREVIEW_CF_DISTRIBUTION_ID }} --paths "/${{ github.event.client_payload.folder }}/*"
100 AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
101 AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
103 - name: Update deployment status to success
104 uses: octokit/request-action@v2.x
106 route: POST /repos/{owner}/{repo}/deployments/{deployment_id}/statuses
111 owner: ${{ github.event.repository.owner.login }}
112 repo: ${{ github.event.repository.name }}
113 deployment_id: ${{ github.event.client_payload.deployment_id }}
115 environment_url: https://preview.openttd.org/${{ github.event.client_payload.folder }}/
117 GITHUB_TOKEN: ${{ secrets.PREVIEW_GITHUB_TOKEN }}
120 name: Update deployment status to failure
121 uses: octokit/request-action@v2.x
123 route: POST /repos/{owner}/{repo}/deployments/{deployment_id}/statuses
128 owner: ${{ github.event.repository.owner.login }}
129 repo: ${{ github.event.repository.name }}
130 deployment_id: ${{ github.event.client_payload.deployment_id }}
133 GITHUB_TOKEN: ${{ secrets.PREVIEW_GITHUB_TOKEN }}