-
Notifications
You must be signed in to change notification settings - Fork 352
131 lines (110 loc) · 3.73 KB
/
update-screenshots.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Update Screenshots
on:
workflow_dispatch:
permissions:
pull-requests: write
contents: 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-22.04
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: Checkout patches
uses: actions/checkout@v4
with:
ref: 'temp-reduce-wasm-size'
path: 'temp-patches'
- name: Apply patches
run: |
git apply --ignore-whitespace temp-patches/desktop-mode.patch
git apply --ignore-whitespace temp-patches/remove-monitor-info-example.patch
git apply --ignore-whitespace temp-patches/remove-remote-protocol-examples.patch
- 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: Create screenshot directory
run: |
mkdir screenshots
- name: Take Screenshots
run: |
xvfb-run cargo run -p example-showcase -- --page ${{ matrix.page }} --per-page ${{ env.PER_PAGE }} run --screenshot-frame 400 --fixed-frame-time 0.0125 --stop-frame 450 --in-ci
- name: Optimize PNGs
continue-on-error: true
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.