Skip to content

publish-docs

publish-docs #1028

Workflow file for this run

name: Publish docs
on:
repository_dispatch:
types:
- publish-docs
# client_payload should contain both fields as mentioned in workflow_dispatch
workflow_dispatch:
inputs:
version:
description: 'The version of the new release, e.g.: 20200101-master-g12345'
required: true
folder:
description: 'The folder in which the release is located openttd-nightlies/2020'
required: true
concurrency: docs
jobs:
publish_docs:
name: Publish docs
runs-on: ubuntu-latest
steps:
- name: Sanity check
shell: bash
run: |
if [ -z "${{ inputs.version || github.event.client_payload.version }}" ]; then
echo "::error::version in client_payload is not set"
exit 1
fi
if [ -z "${{ inputs.folder || github.event.client_payload.folder }}" ]; then
echo "::error::folder in client_payload is not set"
exit 1
fi
if [ -z "${{ secrets.DOCS_CLOUDFLARE_ACCOUNT_ID }}" ]; then
echo "::error::secret DOCS_CLOUDFLARE_ACCOUNT_ID is not set"
exit 1
fi
if [ -z "${{ secrets.DOCS_CLOUDFLARE_API_TOKEN }}" ]; then
echo "::error::secret DOCS_CLOUDFLARE_API_TOKEN is not set"
exit 1
fi
- name: Checkout
uses: actions/checkout@v4
- name: Prepare docs
shell: bash
run: |
VERSION=${{ inputs.version || github.event.client_payload.version }}
FOLDER=${{ inputs.folder || github.event.client_payload.folder }}
# Fetch and extract the docs
curl --fail -s -L -o docs-ai.tar.xz https://cdn.openttd.org/${FOLDER}/${VERSION}/openttd-${VERSION}-docs-ai.tar.xz
curl --fail -s -L -o docs-gs.tar.xz https://cdn.openttd.org/${FOLDER}/${VERSION}/openttd-${VERSION}-docs-gs.tar.xz
curl --fail -s -L -o docs.tar.xz https://cdn.openttd.org/${FOLDER}/${VERSION}/openttd-${VERSION}-docs.tar.xz
tar xf docs-ai.tar.xz
tar xf docs-gs.tar.xz
tar xf docs.tar.xz
mkdir public
cp docs/root/* public/
mv openttd-${VERSION}-docs-ai/html public/ai-api
mv openttd-${VERSION}-docs-gs/html public/gs-api
mv openttd-${VERSION}-docs/html public/source
- name: Publish docs
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.DOCS_CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.DOCS_CLOUDFLARE_ACCOUNT_ID }}
projectName: ${{ vars.DOCS_CLOUDFLARE_PROJECT_NAME }}
directory: public
branch: main