-
-
Notifications
You must be signed in to change notification settings - Fork 10
67 lines (54 loc) · 2.28 KB
/
update-screenshots.yml
File metadata and controls
67 lines (54 loc) · 2.28 KB
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
name: Update Screenshots
on:
workflow_dispatch:
permissions:
contents: write
jobs:
update-screenshots:
name: Update Screenshot References
timeout-minutes: 40
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
lfs: false
ref: ${{ github.ref }}
# LFS is not enabled on checkout (lfs: false) intentionally, we don't need to download all LFS
# objects (e.g. resources/ or store-art/), in fact we don't even need any objects. We only
# need the LFS clean filter to be active so that newly generated screenshot PNGs are committed
# as LFS pointers rather than raw files. Running `git lfs install` sets up that filter without
# pulling anything. This saves on bandwidth.
- name: Setup Git LFS
run: git lfs install
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Update Screenshot Tests
run: ./gradlew androidApp:updateDebugScreenshotTest
- name: Commit updated screenshots to new branch
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
SOURCE_BRANCH="${{ github.ref_name }}"
TARGET_BRANCH="${SOURCE_BRANCH}-update-screenshots"
if [[ "$SOURCE_BRANCH" == "main" ]]; then
echo "::error::Screenshots on 'main' must be updated through a PR, not directly via this workflow."
exit 1
fi
if git ls-remote --exit-code --heads origin "$TARGET_BRANCH" > /dev/null 2>&1; then
echo "::error::Branch '$TARGET_BRANCH' already exists. Please review and delete it before running this workflow again."
exit 1
fi
git checkout -b "$TARGET_BRANCH"
git add androidApp/src/screenshotTestDebug/reference/
if git diff --cached --quiet; then
echo "No screenshot changes detected, nothing to commit."
else
git commit -m "Update screenshot test references"
git push origin "$TARGET_BRANCH"
echo "Pushed updated screenshots to branch: $TARGET_BRANCH"
fi