Update screenshot.yml #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: | | |
| cd iblot # Move into the correct directory | |
| xcodebuild test \ | |
| -project iblot.xcodeproj \ | |
| -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 "" >> 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 |