Publish dev-docs with Github Pages artifacts (2nd attempt) (#10892)

Supersedes #10888.

# Objective

Closes #10821

## Solution

- Replaced
[JamesIves/github-pages-deploy-action](https://github.com/JamesIves/github-pages-deploy-action)
with
[actions/upload-pages-artifact](https://github.com/actions/upload-pages-artifact)
and [actions/deploy-pages](https://github.com/actions/deploy-pages).

## Notes

- I made this workflow possible to run through dispatch
(`workflow_dispatch`), in case something goes wrong.
- I restricted the permissions to just the things Github Pages needs.
- I made it so that only one deployments can happen at a time, the other
deployment requests will be queued up and the latest one will be run.
This commit is contained in:
BD103 2024-01-02 13:13:31 -05:00 committed by GitHub
parent ab10e85558
commit 1a2a184350
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,13 +5,30 @@ on:
branches:
- 'main'
# Allows running the action manually.
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
RUSTDOCFLAGS: --html-in-header header.html
# Sets the permissions to allow deploying to Github pages.
permissions:
contents: read
pages: write
id-token: write
# Only allow one deployment to run at a time, however it will not cancel in-progress runs.
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout
uses: actions/checkout@v4
@ -37,19 +54,17 @@ jobs:
# - A top level redirect to the bevy crate documentation
# - A CNAME file for redirecting the docs domain to the API reference
# - A robots.txt file to forbid any crawling of the site (to defer to the docs.rs site on search engines).
# - A .nojekyll file to disable Jekyll GitHub Pages builds.
- name: Finalize documentation
run: |
echo "<meta http-equiv=\"refresh\" content=\"0; url=bevy/index.html\">" > target/doc/index.html
echo "dev-docs.bevyengine.org" > target/doc/CNAME
echo "User-Agent: *\nDisallow: /" > target/doc/robots.txt
touch target/doc/.nojekyll
- name: Deploy
if: github.repository == 'bevyengine/bevy'
uses: JamesIves/github-pages-deploy-action@v4
- name: Upload site artifact
uses: actions/upload-pages-artifact@v1
with:
branch: gh-pages
folder: target/doc
single-commit: true
force: true
path: target/doc
- name: Deploy to Github Pages
id: deployment
uses: actions/deploy-pages@v2