1- name : Capture iOS Screenshots
1+ name : UI Test Screenshots
22
33on :
44 push :
55 branches :
6- - main # Change this if your default branch is different
6+ - main
7+ pull_request :
78
89jobs :
910 screenshot :
@@ -13,33 +14,35 @@ jobs:
1314 uses : actions/checkout@v4
1415
1516 - name : Set Up Xcode
16- run : sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
17+ run : sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
1718
1819 - name : Build & Run UI Tests
1920 run : |
2021 xcodebuild test \
21- -workspace iblot.xcworkspace \
22+ -project iblot.xcodeproj \ # ✅ Use .xcodeproj (not .xcworkspace)
2223 -scheme iblot \
2324 -destination 'platform=iOS Simulator,name=iPhone 14,OS=latest' \
24- -only-testing iblotUITests/testExample
25+ -resultBundlePath TestResults.xcresult
2526
26- - name : Find Screenshots
27+ - name : Extract Screenshot
2728 run : |
2829 mkdir -p Screenshots
29- find ~/Library/Developer/Xcode/DerivedData -name "*.png" -exec cp {} Screenshots/ \;
30-
31- - name : Commit and Push Screenshots
32- run : |
33- git config --global user.name "github-actions[bot]"
34- git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
35- git add Screenshots/*
36- git commit -m "Update screenshots" || echo "No changes to commit"
37- git push
30+ xcrun xcresulttool get --path TestResults.xcresult --format json | jq -r '.actions.invocationRecord.actions[].results[].attachments[].payloadRef | select(.filename | test(".*.png$")) | .id' | while read -r id; do
31+ xcrun xcresulttool export --type file --path TestResults.xcresult --id "$id" --output-path "Screenshots/screenshot.png"
32+ done
3833
39- - name : Update README with latest screenshot
34+ - name : Upload Screenshot Artifact
35+ uses : actions/upload-artifact@v4
36+ with :
37+ name : screenshots
38+ path : Screenshots/screenshot.png
39+
40+ - name : Update README with Screenshot
4041 run : |
41- LATEST_IMAGE=$(ls -t Screenshots | head -1)
42- echo "" > README.md
42+ echo "## Latest Screenshot" > README.md
43+ echo "" >> README.md
44+ git config --global user.name "github-actions[bot]"
45+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
4346 git add README.md
44- git commit -m "Update README with latest screenshot" || echo "No changes to commit"
45- git push
47+ git commit -m "Update README with latest screenshot"
48+ git push origin main
0 commit comments