Skip to content

Update screenshot.yml #5

Update screenshot.yml

Update screenshot.yml #5

Workflow file for this run

name: UI Test Screenshots
on:
push:
branches:
- main
pull_request:
jobs:
screenshot:
runs-on: macos-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set Up Xcode
run: sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
- name: Build & Run UI Tests
run: |
xcodebuild test \
-project iblot.xcodeproj \ # ✅ Use .xcodeproj (not .xcworkspace)
-scheme iblot \
-destination 'platform=iOS Simulator,name=iPhone 14,OS=latest' \
-resultBundlePath TestResults.xcresult
- name: Extract Screenshot
run: |
mkdir -p Screenshots
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
xcrun xcresulttool export --type file --path TestResults.xcresult --id "$id" --output-path "Screenshots/screenshot.png"
done
- name: Upload Screenshot Artifact
uses: actions/upload-artifact@v4
with:
name: screenshots
path: Screenshots/screenshot.png
- name: Update README with Screenshot
run: |
echo "## Latest Screenshot" > README.md
echo "![](Screenshots/screenshot.png)" >> README.md
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add README.md
git commit -m "Update README with latest screenshot"
git push origin main