Deploy #124
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
name: Deploy | |
on: | |
workflow_dispatch: | |
inputs: | |
run-id: | |
description: The run-id of the workflow to fetch the artifacts from | |
required: true | |
type: number | |
toit-version: | |
description: 'The version of the Toit documentation to fetch' | |
required: true | |
type: string | |
toitlang-run-id: | |
description: 'The run-id of the toitlang/toit workflow to fetch the Toit documentation from' | |
required: false | |
type: string | |
default: | |
env: | |
REPOSITORY: toitware/web-toitdocs | |
TOITDOC_REPOSITORY: toitlang/toit | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Show inputs | |
if: github.event_name == 'workflow_dispatch' | |
run: echo "${{ toJSON(github.event.inputs) }}" | |
# No need to checkout the project, since all we need is to download the | |
# build artifact from the build step. | |
- uses: actions/download-artifact@v4 | |
with: | |
repository: ${{ env.REPOSITORY }} | |
github-token: ${{ secrets.LEON_REPOSITORY_DISPATCH }} | |
run-id: ${{ github.event.inputs.run-id }} | |
name: build | |
path: build | |
- name: Disable Jekyll | |
run: | | |
touch build/.nojekyll | |
- name: Untar | |
run: | | |
cd build | |
tar x -zf *.tar.gz | |
rm *.tar.gz | |
- name: Fetch Toit documentation from run-id | |
if: ${{ github.event.inputs.toitlang-run-id }} | |
uses: actions/download-artifact@v4 | |
with: | |
repository: ${{ env.TOITDOC_REPOSITORY }} | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
run-id: ${{ github.event.inputs.toitlang-run-id }} | |
name: toitdoc | |
path: toitdoc-download | |
- name: Move toitdocs. | |
if: ${{ github.event.inputs.toitlang-run-id }} | |
run: | | |
mv toitdoc-download/*.json build/toitdoc.json | |
- name: Fetch Toit documentation | |
if: ${{ github.event.inputs.toitlang-run-id == '' }} | |
run: | | |
# Fetch the Toit documentation from the GitHub release page. | |
VERSION=${{ github.event.inputs.toit-version }} | |
if [[ -z "$VERSION" || "$VERSION" == "latest" ]]; then | |
URL=https://github.com/toitlang/toit/releases/latest/download/toitdoc.json | |
else | |
URL=https://github.com/toitlang/toit/releases/download/$VERSION/toitdoc.json | |
fi | |
echo "Fetching Toit documentation from $URL" | |
mkdir -p build | |
curl -L $URL -o build/toitdoc.json | |
# This seems to be the simplest way to publish to a separate branch. | |
- name: Deploy | |
uses: peaceiris/actions-gh-pages@v4 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_branch: gh-pages | |
publish_dir: ./build | |
# Optional. This will create a CNAME file so GitHub Pages serves it | |
# under this domain. | |
cname: libs-dev.toit.io |