Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: workflow to automate publishing of documentation
- Loading branch information
Showing
5 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: New OpenTTD release | ||
|
||
on: | ||
repository_dispatch: | ||
types: | ||
- new_tag | ||
- new_master | ||
|
||
jobs: | ||
new_release: | ||
name: New OpenTTD release | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Trigger website (staging) | ||
uses: peter-evans/repository-dispatch@v1 | ||
with: | ||
token: ${{ secrets.DEPLOYMENT_TOKEN }} | ||
repository: OpenTTD/website | ||
event-type: publish_master | ||
|
||
- name: Trigger website (Production) | ||
uses: peter-evans/repository-dispatch@v1 | ||
with: | ||
token: ${{ secrets.DEPLOYMENT_TOKEN }} | ||
repository: OpenTTD/website | ||
event-type: publish_latest_tag | ||
|
||
- if: github.event.action == 'new_master' | ||
name: Trigger docs | ||
uses: peter-evans/repository-dispatch@v1 | ||
with: | ||
token: ${{ secrets.DEPLOYMENT_TOKEN }} | ||
repository: OpenTTD/workflows | ||
event-type: publish_docs | ||
client-payload: '{"version": "${{ github.event.client_payload.version }}"}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Publish docs | ||
|
||
on: | ||
repository_dispatch: | ||
types: | ||
- publish_docs | ||
|
||
jobs: | ||
publish_docs: | ||
name: Publish docs | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Publish docs | ||
run: | | ||
set -x | ||
VERSION=${{ github.event.client_payload.version }} | ||
if [ -z "${VERSION}" ]; then | ||
echo "::error::version in client_payload is not set" | ||
exit 1 | ||
fi | ||
if [ -z "${{ secrets.S3_BUCKET }}" ]; then | ||
echo "::error::secret S3_BUCKET is not set" | ||
exit 1 | ||
fi | ||
if [ -z "${{ secrets.CF_DISTRIBUTION_ID }}" ]; then | ||
echo "::error::secret CF_DISTRIBUTION_ID is not set" | ||
exit 1 | ||
fi | ||
# Fetch and extract the docs | ||
curl --fail -s -L -o docs-ai.tar.xz https://proxy.binaries.openttd.org/openttd-nightlies/${VERSION}/openttd-${VERSION}-docs-ai.tar.xz | ||
curl --fail -s -L -o docs-gs.tar.xz https://proxy.binaries.openttd.org/openttd-nightlies/${VERSION}/openttd-${VERSION}-docs-gs.tar.xz | ||
curl --fail -s -L -o docs.tar.xz https://proxy.binaries.openttd.org/openttd-nightlies/${VERSION}/openttd-${VERSION}-docs.tar.xz | ||
tar xf docs-ai.tar.xz | ||
tar xf docs-gs.tar.xz | ||
tar xf docs.tar.xz | ||
# Sync all the new/modified files | ||
aws s3 sync --only-show-errors docs/root/ s3://${{ secrets.S3_BUCKET }}/ | ||
aws s3 sync --only-show-errors docs/errors/ s3://${{ secrets.S3_BUCKET }}/errors/ | ||
aws s3 sync --only-show-errors openttd-${VERSION}-docs-ai/html/ s3://${{ secrets.S3_BUCKET }}/ai-api/ | ||
aws s3 sync --only-show-errors openttd-${VERSION}-docs-gs/html/ s3://${{ secrets.S3_BUCKET }}/gs-api/ | ||
aws s3 sync --only-show-errors openttd-${VERSION}-docs/html/ s3://${{ secrets.S3_BUCKET }}/source/ | ||
# Delete any unknown file; this is a separate step, as 'aws s3 sync' | ||
# can delete before uploading, which could mean files temporary link | ||
# to invalid files. | ||
aws s3 sync --only-show-errors --delete docs/errors/ s3://${{ secrets.S3_BUCKET }}/errors/ | ||
aws s3 sync --only-show-errors --delete openttd-${VERSION}-docs-ai/html/ s3://${{ secrets.S3_BUCKET }}/ai-api/ | ||
aws s3 sync --only-show-errors --delete openttd-${VERSION}-docs-gs/html/ s3://${{ secrets.S3_BUCKET }}/gs-api/ | ||
aws s3 sync --only-show-errors --delete openttd-${VERSION}-docs/html/ s3://${{ secrets.S3_BUCKET }}/source/ | ||
# Invalidate the cache of the CloudFront distribution | ||
aws cloudfront create-invalidation --distribution-id ${{ secrets.CF_DISTRIBUTION_ID }} --paths "/*" | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# OpenTTD's workflows | ||
|
||
To automate all kinds of things, we use GitHub Actions, and especially, their workflow. | ||
This repository runs a few workflows that don't belong to a repository we have. | ||
|
||
## Workflows | ||
|
||
- [New OpenTTD Release](.github/workflows/new_openttd_release.yml): workflow that is triggered when a new OpenTTD binary is produced | ||
- [Publish Docs](.github/workflows/publish_docs.yml): publishes the HTML docs to https://docs.openttd.org/ based on an openttd-nightly version. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>404 - Not Found</title> | ||
</head> | ||
<body> | ||
<main> | ||
<h1>404 - Not Found</h1> | ||
</main> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>OpenTTD documentation</title> | ||
</head> | ||
<body> | ||
<main> | ||
<h1>OpenTTD documentation</h1> | ||
<a href="ai-api/index.html">AI API documentation</a><br /> | ||
<a href="gs-api/index.html">GS API documentation</a><br /> | ||
<a href="source/index.html">Source documentation</a><br /> | ||
</main> | ||
</body> | ||
</html> |