2020-12-08 12:49:22 +00:00
|
|
|
name: Preview build
|
|
|
|
|
|
|
|
on:
|
|
|
|
repository_dispatch:
|
|
|
|
types:
|
|
|
|
- Preview*
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
preview:
|
|
|
|
name: Build preview
|
|
|
|
|
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
container:
|
|
|
|
# If you change this version, change the number in the cache step too.
|
2021-10-03 14:20:05 +00:00
|
|
|
image: emscripten/emsdk:2.0.31
|
2020-12-08 12:49:22 +00:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Update deployment status to in progress
|
|
|
|
uses: octokit/request-action@v2.x
|
|
|
|
with:
|
|
|
|
route: POST /repos/{owner}/{repo}/deployments/{deployment_id}/statuses
|
|
|
|
mediaType: |
|
|
|
|
previews:
|
|
|
|
- ant-man
|
|
|
|
- flash
|
|
|
|
owner: ${{ github.event.repository.owner.login }}
|
|
|
|
repo: ${{ github.event.repository.name }}
|
|
|
|
deployment_id: ${{ github.event.client_payload.deployment_id }}
|
|
|
|
state: in_progress
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.PREVIEW_GITHUB_TOKEN }}
|
|
|
|
|
|
|
|
- name: Checkout
|
2022-05-13 06:40:39 +00:00
|
|
|
uses: actions/checkout@v3
|
2020-12-08 12:49:22 +00:00
|
|
|
with:
|
|
|
|
ref: ${{ github.event.client_payload.sha }}
|
|
|
|
|
|
|
|
- name: Name branch
|
|
|
|
run: |
|
|
|
|
name=$(echo "${{ github.event.client_payload.folder }}")
|
|
|
|
git checkout -b ${name}
|
|
|
|
|
|
|
|
- name: Setup cache
|
2022-05-13 06:40:09 +00:00
|
|
|
uses: actions/cache@v3
|
2020-12-08 12:49:22 +00:00
|
|
|
with:
|
|
|
|
path: /emsdk/upstream/emscripten/cache
|
2021-10-03 14:20:05 +00:00
|
|
|
key: 2.0.31-${{ runner.os }}
|
|
|
|
|
|
|
|
- name: Patch Emscripten to support LZMA
|
|
|
|
run: |
|
|
|
|
cd /emsdk/upstream/emscripten
|
|
|
|
patch -p1 < ${GITHUB_WORKSPACE}/os/emscripten/emsdk-liblzma.patch
|
2020-12-08 12:49:22 +00:00
|
|
|
|
|
|
|
- name: Build (host tools)
|
|
|
|
run: |
|
|
|
|
mkdir build-host
|
|
|
|
cd build-host
|
|
|
|
|
|
|
|
echo "::group::CMake"
|
|
|
|
cmake .. -DOPTION_TOOLS_ONLY=ON
|
|
|
|
echo "::endgroup::"
|
|
|
|
|
|
|
|
echo "::group::Build"
|
|
|
|
echo "Running on $(nproc) cores"
|
|
|
|
make -j$(nproc) tools
|
|
|
|
echo "::endgroup::"
|
|
|
|
|
|
|
|
- name: Install GCC problem matcher
|
|
|
|
uses: ammaraskar/gcc-problem-matcher@master
|
|
|
|
|
|
|
|
- name: Build
|
|
|
|
run: |
|
|
|
|
mkdir build
|
|
|
|
cd build
|
|
|
|
|
|
|
|
echo "::group::CMake"
|
|
|
|
emcmake cmake .. \
|
|
|
|
-DHOST_BINARY_DIR=../build-host \
|
2021-11-14 15:59:49 +00:00
|
|
|
-DCMAKE_BUILD_TYPE=Release \
|
2020-12-08 12:49:22 +00:00
|
|
|
# EOF
|
|
|
|
echo "::endgroup::"
|
|
|
|
|
|
|
|
echo "::group::Build"
|
|
|
|
echo "Running on $(nproc) cores"
|
|
|
|
emmake make -j$(nproc)
|
|
|
|
echo "::endgroup::"
|
|
|
|
|
|
|
|
- name: Publish preview
|
|
|
|
run: |
|
|
|
|
pip3 install awscli
|
|
|
|
|
2021-10-17 20:42:29 +00:00
|
|
|
aws s3 cp --only-show-errors build/openttd.data s3://${{ secrets.PREVIEW_S3_BUCKET }}/${{ github.event.client_payload.folder }}/
|
|
|
|
aws s3 cp --only-show-errors build/openttd.html s3://${{ secrets.PREVIEW_S3_BUCKET }}/${{ github.event.client_payload.folder }}/
|
|
|
|
aws s3 cp --only-show-errors build/openttd.js s3://${{ secrets.PREVIEW_S3_BUCKET }}/${{ github.event.client_payload.folder }}/
|
|
|
|
aws s3 cp --only-show-errors build/openttd.wasm s3://${{ secrets.PREVIEW_S3_BUCKET }}/${{ github.event.client_payload.folder }}/
|
2020-12-08 12:49:22 +00:00
|
|
|
|
|
|
|
# Invalidate the cache of the CloudFront distribution
|
2021-10-17 20:42:29 +00:00
|
|
|
aws cloudfront create-invalidation --distribution-id ${{ secrets.PREVIEW_CF_DISTRIBUTION_ID }} --paths "/${{ github.event.client_payload.folder }}/*"
|
2020-12-08 12:49:22 +00:00
|
|
|
env:
|
|
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
|
|
|
|
|
|
- name: Update deployment status to success
|
|
|
|
uses: octokit/request-action@v2.x
|
|
|
|
with:
|
|
|
|
route: POST /repos/{owner}/{repo}/deployments/{deployment_id}/statuses
|
|
|
|
mediaType: |
|
|
|
|
previews:
|
|
|
|
- ant-man
|
|
|
|
- flash
|
|
|
|
owner: ${{ github.event.repository.owner.login }}
|
|
|
|
repo: ${{ github.event.repository.name }}
|
|
|
|
deployment_id: ${{ github.event.client_payload.deployment_id }}
|
|
|
|
state: success
|
|
|
|
environment_url: https://preview.openttd.org/${{ github.event.client_payload.folder }}/
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.PREVIEW_GITHUB_TOKEN }}
|
|
|
|
|
|
|
|
- if: failure()
|
|
|
|
name: Update deployment status to failure
|
|
|
|
uses: octokit/request-action@v2.x
|
|
|
|
with:
|
|
|
|
route: POST /repos/{owner}/{repo}/deployments/{deployment_id}/statuses
|
|
|
|
mediaType: |
|
|
|
|
previews:
|
|
|
|
- ant-man
|
|
|
|
- flash
|
|
|
|
owner: ${{ github.event.repository.owner.login }}
|
|
|
|
repo: ${{ github.event.repository.name }}
|
|
|
|
deployment_id: ${{ github.event.client_payload.deployment_id }}
|
|
|
|
state: failure
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.PREVIEW_GITHUB_TOKEN }}
|