Skip to content

Commit f3aeb3d

Browse files
Fix screenshot copy issue in pr-screenshot branch workflow
The script was trying to copy screenshots after switching to the pr-screenshot branch, but that branch is an orphan branch without the test/ directory. Fixed by: - Copying screenshots to a temp directory BEFORE switching branches - Using the temp directory as the source when copying to the PR folder - Cleaning up the temp directory after copying This ensures screenshots are always available regardless of which branch we're on. Co-authored-by: richardthe3rd <573334+richardthe3rd@users.noreply.github.com>
1 parent 69f201c commit f3aeb3d

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

scripts/update_screenshot_branch.sh

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ echo "Updating screenshots to branch: $BRANCH_NAME"
2323
echo "PR folder: $PR_FOLDER"
2424
echo "Source branch: $SOURCE_BRANCH"
2525

26+
# Store the current directory to return to it
27+
ORIGINAL_DIR=$(pwd)
28+
29+
# Copy screenshots to a temp directory BEFORE switching branches
30+
TEMP_DIR=$(mktemp -d)
31+
echo "Copying screenshots to temporary directory: $TEMP_DIR"
32+
cp test/screenshots/goldens/*.png "$TEMP_DIR/" || {
33+
echo "Error: No screenshot files found in test/screenshots/goldens/"
34+
exit 1
35+
}
36+
2637
# Configure git
2738
git config --local user.email "github-actions[bot]@users.noreply.github.com"
2839
git config --local user.name "github-actions[bot]"
@@ -73,9 +84,12 @@ fi
7384
echo "Creating/updating $PR_FOLDER directory..."
7485
mkdir -p "$PR_FOLDER"
7586

76-
# Copy screenshots to the PR folder
77-
echo "Copying screenshots to $PR_FOLDER..."
78-
cp test/screenshots/goldens/*.png "$PR_FOLDER/"
87+
# Copy screenshots from temp directory to the PR folder
88+
echo "Copying screenshots from temp directory to $PR_FOLDER..."
89+
cp "$TEMP_DIR"/*.png "$PR_FOLDER/"
90+
91+
# Clean up temp directory
92+
rm -rf "$TEMP_DIR"
7993

8094
# Add and commit
8195
git add "$PR_FOLDER"/*.png

0 commit comments

Comments
 (0)