github action, screenshots #1
This file contains 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: Flutter Screenshot | |
on: [push, pull_request] | |
jobs: | |
take_screenshots: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: 'stable' | |
- name: Install dependencies | |
run: flutter pub get | |
- name: Ensure screenshots.md exists | |
run: | | |
if [ ! -f screenshots.md ]; then | |
echo "# Screenshots" > screenshots.md | |
fi | |
- name: Run tests and take screenshots | |
run: | | |
sudo apt-get install -y xvfb | |
xvfb-run -s "-screen 0 360x800x24" flutter drive --target=test_driver/screenshot_test.dart | |
mkdir -p screenshots | |
cp build/screenshots/*.png screenshots/ | |
- name: Commit and push screenshots | |
run: | | |
git config --global user.name 'github-actions' | |
git config --global user.email 'github-actions@github.com' | |
git add screenshots/ | |
git commit -m 'Update screenshots' | |
git push | |
- name: Update screenshots.md | |
run: | | |
sed -i '/## Screenshots/q' screenshots.md | |
for screenshot in screenshots/*.png; do | |
echo "![Screenshot](./$screenshot)" >> screenshots.md | |
done | |
git add screenshots.md | |
git commit -m 'Update screenshots.md with screenshots' | |
git push |