Skip to content

Commit b7e083b

Browse files
authored
Merge pull request #173 from mathoudebine/feature/auto-commit-theme-preview
Auto-commit theme previews on master/release push
2 parents fbcf68b + 83769b7 commit b7e083b

File tree

2 files changed

+70
-6
lines changed

2 files changed

+70
-6
lines changed

.github/workflows/themes-screenshot.yml renamed to .github/workflows/themes-screenshot-on-pr.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
name: System monitor - themes screenshot
1+
name: System monitor - themes screenshot (on PR)
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
- 'releases/**'
84
pull_request:
95

106
jobs:
@@ -53,7 +49,7 @@ jobs:
5349
killall -9 python3
5450

5551
# Rename screen capture
56-
cp screencap.png screenshot-$theme.png
52+
cp screencap.png "screenshot-$theme.png"
5753
fi
5854
done
5955

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: System monitor - themes screenshot (on push)
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- 'releases/**'
8+
9+
jobs:
10+
system-monitor-theme-screenshot:
11+
12+
runs-on: ubuntu-latest
13+
14+
permissions:
15+
# Give the default GITHUB_TOKEN write permission to commit and push the
16+
# added or changed files to the repository.
17+
contents: write
18+
19+
strategy:
20+
fail-fast: false
21+
22+
steps:
23+
- uses: actions/checkout@v3
24+
- name: Set up Python 3.10
25+
uses: actions/setup-python@v4
26+
with:
27+
python-version: "3.10"
28+
29+
- name: Install dependencies
30+
run: |
31+
python -m pip install --upgrade pip
32+
python -m pip install -r requirements.txt
33+
34+
- name: Configure system monitor for screenshot
35+
run: |
36+
# For tests there is no real HW: use simulated LCD mode
37+
sed -i "/REVISION:/c\ REVISION: SIMU" config.yaml
38+
39+
# Use static data
40+
sed -i "/HW_SENSORS:/c\ HW_SENSORS: STATIC" config.yaml
41+
42+
- name: Run system monitor for 5 seconds on all themes
43+
run: |
44+
for dir in res/themes/*/
45+
do
46+
if test -f "$dir/theme.yaml"; then
47+
# Keep only folder name
48+
theme=`basename ${dir%*/}`
49+
50+
# Setup selected theme in config.yaml
51+
echo "Using theme $theme"
52+
sed -i "/THEME:/c\ THEME: $theme" config.yaml
53+
54+
# Run system-monitor for 5 seconds
55+
python3 main.py > output.log 2>&1 &
56+
sleep 5
57+
killall -9 python3
58+
59+
# Copy screen capture on theme folder
60+
cp screencap.png "$dir/preview.png"
61+
fi
62+
done
63+
64+
- name: Commit theme previews
65+
uses: stefanzweifel/git-auto-commit-action@v4
66+
with:
67+
commit_message: "[GitHub Actions Bot] Update theme previews"
68+
file_pattern: 'res/themes/*/preview.png'

0 commit comments

Comments
 (0)