Update Screenshots #11
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: Update Screenshots | |
on: | |
workflow_dispatch: | |
permissions: | |
pull-requests: write | |
env: | |
PER_PAGE: 20 | |
jobs: | |
prepare-pages: | |
name: Get Pages | |
runs-on: ubuntu-latest | |
outputs: | |
pages: ${{ steps.pages.outputs.pages }} | |
steps: | |
- name: Checkout Bevy main branch | |
uses: actions/checkout@v4 | |
with: | |
repository: 'bevyengine/bevy' | |
ref: 'latest' | |
- name: Get Pages | |
id: pages | |
run: | | |
example_count=`cat Cargo.toml | grep '\[\[example\]\]' | wc -l` | |
page_count=$((example_count / ${{ env.PER_PAGE }} + 1)) | |
echo "pages=`jq -n -c \"[range($page_count)]\"`" >> $GITHUB_OUTPUT | |
take-screenshots: | |
name: Take Screenshots | |
needs: prepare-pages | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
page: ${{ fromJSON(needs.prepare-pages.outputs.pages) }} | |
steps: | |
- name: Checkout Bevy latest tag | |
uses: actions/checkout@v4 | |
with: | |
repository: 'bevyengine/bevy' | |
ref: 'latest' | |
- name: Setup Rust | |
uses: dtolnay/rust-toolchain@stable | |
- name: Install Bevy dependencies | |
run: | | |
sudo apt-get update; | |
DEBIAN_FRONTEND=noninteractive sudo apt-get install --no-install-recommends -yq \ | |
libasound2-dev libudev-dev libxkbcommon-x11-0; | |
- name: Install xvfb, llvmpipe and lavapipe | |
run: | | |
sudo apt-get update -y -qq | |
sudo add-apt-repository ppa:kisak/turtle -y | |
sudo apt-get update | |
sudo apt install -y xvfb libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers | |
- name: Install oxipng | |
run: | | |
cargo install oxipng --version ^9.1.1 | |
- name: Take Screenshots | |
run: | | |
xvfb-run cargo run -p example-showcase -- --page ${{ matrix.page }} --per-page ${{ env.PER_PAGE }} run --screenshot --in-ci | |
- name: Optimize PNGs | |
run: | | |
oxipng --opt max --strip safe --recursive screenshots | |
- name: Upload Generated Files | |
uses: actions/upload-artifact@v4 | |
with: | |
name: screenshots-${{ matrix.page }} | |
path: screenshots | |
prepare-pr: | |
name: Prepare Screenshots Update PR | |
runs-on: ubuntu-latest | |
needs: take-screenshots | |
permissions: | |
pull-requests: write | |
contents: write | |
steps: | |
- name: Clone bevy-website repo | |
uses: actions/checkout@v4 | |
- name: Download all artifacts | |
uses: actions/download-artifact@v4 | |
- name: Move examples to the correct folder | |
run: | | |
rm -rf static/screenshots | |
mkdir static/screenshots | |
for file in screenshots-* | |
do | |
rsync -a $file/* static/screenshots/ | |
rm -rf $file | |
done | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
delete-branch: true | |
branch-suffix: random | |
title: Update Examples Screenshots | |
body: | | |
This PR updates the screenshots of the examples with latest version from Bevy. | |
It was automatically generated by a GitHub Action. |