Publish Site #27
This file contains hidden or 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: Publish Site | |
on: | |
schedule: | |
- cron: "0 0 * * *" | |
workflow_dispatch: | |
env: | |
EMMYLUA_CLI_VERSION: "0.6.0" | |
jobs: | |
publish: | |
if: github.repository == 'beyond-all-reason/spring' || github.event_name == 'workflow_dispatch' | |
name: Publish Site | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Install Dependencies | |
run: | | |
sudo apt-get update -y | |
sudo apt-get install --fix-missing -y jq p7zip-full libsdl2-2.0-0 libopenal1 | |
- name: Checkout Source Repository | |
uses: actions/checkout@v2 | |
- name: Generate Dynamic Content | |
run: | | |
bash doc/site/_scripts/get_release_data.sh | |
bash doc/site/_scripts/get_engine_data.sh | |
git add -f doc/site/_data | |
# NOTE: This step is duplicated in `generate-lua-library.yml` | |
- name: Generate Lua library | |
run: | | |
npm install -g lua-doc-extractor@3 | |
lua-doc-extractor rts/Lua/*.cpp \ | |
--dest rts/Lua/library/generated \ | |
--repo https://github.com/${{ github.repository }}/blob/${{ github.sha }} | |
# Upload the Lua library artifact for debugging. | |
- name: Upload Lua Library artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{github.run_id}}-library | |
path: rts/Lua/library/ | |
- name: Install emmylua_doc_cli | |
run: | | |
cargo install emmylua_doc_cli --version "${EMMYLUA_CLI_VERSION}" | |
- name: Generate docs using emmylua_doc_cli | |
run: | | |
emmylua_doc_cli \ | |
-i rts/Lua/library \ | |
-o doc/site/lua-api \ | |
--override-template doc/emmlua-doc-cli-template | |
git add -f doc/site/lua-api | |
- name: Commit changes | |
run: | | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
git commit -m "Update doc/site/lua-api" | |
- name: Check if gh-pages exists | |
id: check-ghpages | |
run: | | |
git fetch origin gh-pages | |
git ls-remote --exit-code . origin/gh-pages && (echo "exists=true" > $GITHUB_OUTPUT) || (echo "exists=false" > $GITHUB_OUTPUT) | |
- name: Check changes to doc/site | |
id: site-changes | |
if: steps.check-ghpages.outputs.exists == 'true' | |
run: | | |
git diff --stat origin/gh-pages ${{ github.ref_name }}:doc/site | |
git diff --quiet origin/gh-pages ${{ github.ref_name }}:doc/site && (echo "modified=false" > $GITHUB_OUTPUT) || (echo "modified=true" > $GITHUB_OUTPUT) | |
- name: Push gh-pages # Only push gh-pages if doc/site/ was changed or ldoc did changes | |
if: steps.check-ghpages.outputs.exists == 'false' || steps.site-changes.outputs.modified == 'true' | |
run: | | |
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY | |
git subtree split --prefix=doc/site --rejoin -b gh-pages | |
git push origin gh-pages --force |