Skip to content

Commit

Permalink
Use companion branch to store screenshot test result.
Browse files Browse the repository at this point in the history
  • Loading branch information
eneim committed Sep 20, 2022
1 parent 99f0344 commit 50530e7
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions .github/workflows/ScreenShotTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,31 +46,32 @@ jobs:
name: screenshot-test-results
path: preview-screenshots/out/failures

- name: Checkout the docs branch
- name: New checkout for the companion branch
id: checkout_docs
if: ${{ hashFiles('preview-screenshots/out/failures/*.png') != '' }}
uses: actions/checkout@v3
with:
path: temp_docs
ref: docs

- name: Commit the screenshot to the branch
id: docs_images
if: steps.checkout_docs.outcome == 'success'
continue-on-error: true # https://github.com/DroidKaigi/conference-app-2022/issues/497
env:
BRANCH_NAME: companion_${{ github.head_ref || github.ref_name }}
run: |
cp -a preview-screenshots/out/failures/. temp_docs/docs/screenshots/
cd temp_docs/
if ! git diff --exit-code --quiet
then
git add . --update
git commit -m "Upload screenshots to github page."
git push
sleep 3 # wait 3 minutes for github page to update
fi
git switch -C $BRANCH_NAME
mkdir -p docs/screenshots/
cp -a ../preview-screenshots/out/failures/. docs/screenshots/
git add .
git config --global push.default current
git config --global remote.pushDefault origin
git commit -m "Upload screenshots to github page."
git push -f
cd ..
cd preview-screenshots/out/failures
echo ::set-output name=images::$(ls | jq -R -s -c 'split("\n")[:-1]' | jq -r '.[] |= "https://droidkaigi.github.io/conference-app-2022/screenshots/" + .')
echo ::set-output name=images::$(ls | jq -R -s -c 'split("\n")[:-1]' | jq -r --arg IMAGE_PATH "https://raw.githubusercontent.com/eneim/conference-app-2022/$BRANCH_NAME/docs/screenshots/" '.[] |= $IMAGE_PATH + .')
- name: Build PR Comment with Preview
id: pr_comment
Expand All @@ -80,7 +81,8 @@ jobs:
ALL_SCREENSHOTS: ${{ steps.docs_images.outputs.images }}
# Build a comment message with the image from snapshot images for demo purpose.
run: |
echo "There are differences in Compose previews." > report.md
echo "There are differences in Compose previews:" > report.md
echo >> report.md # A blank line.
echo "$ALL_SCREENSHOTS" | jq -r '.[]' | while read -r image; do
echo "![]($image)" >> report.md
done
Expand Down

0 comments on commit 50530e7

Please sign in to comment.