fix: skip auto-commit of visual regression screenshots for fork PRs

This commit is contained in:
kiloconnect[bot]
2026-03-09 10:24:13 +00:00
parent 4ae308cc33
commit 8dcf7407e3
+57 -4
View File
@@ -10,6 +10,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
matched: ${{ steps.filter.outputs.matched }}
is_fork: ${{ steps.fork-check.outputs.is_fork }}
steps:
- uses: actions/checkout@v4
- uses: Kilo-Org/paths-filter@master
@@ -25,6 +26,14 @@ jobs:
- "packages/kilo-vscode/.storybook/**"
- "packages/kilo-vscode/tests/visual-regression*"
- ".github/workflows/visual-regression.yml"
- name: Check if PR is from a fork
id: fork-check
run: |
if [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]; then
echo "is_fork=true" >> "$GITHUB_OUTPUT"
else
echo "is_fork=false" >> "$GITHUB_OUTPUT"
fi
visual-regression:
needs: check-paths
@@ -34,13 +43,20 @@ jobs:
timeout-minutes: 15
steps:
- name: Checkout
- name: Checkout (internal)
if: needs.check-paths.outputs.is_fork != 'true'
uses: actions/checkout@v4
with:
lfs: true
token: ${{ secrets.BOT_PAT }}
ref: ${{ github.head_ref }}
- name: Checkout (fork)
if: needs.check-paths.outputs.is_fork == 'true'
uses: actions/checkout@v4
with:
lfs: true
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
@@ -90,7 +106,22 @@ jobs:
CI: true
PLAYWRIGHT_WORKERS: "4"
- name: Check for baseline changes (fork PRs)
if: needs.check-paths.outputs.is_fork == 'true'
run: |
git add packages/kilo-ui/tests/visual-regression.spec.ts-snapshots/
if git diff --cached --quiet; then
echo "No visual regression detected."
else
echo "::error::Visual regression detected. Screenshot baselines have changed."
echo "::error::Since this PR is from a fork, updated screenshots cannot be committed automatically."
echo "::error::Please update your screenshots locally by running 'bun run test:visual:update' in packages/kilo-ui/ and commit the results."
git diff --cached --stat
exit 1
fi
- name: Commit and push new baselines (if any)
if: needs.check-paths.outputs.is_fork != 'true'
id: commit-baselines
env:
GH_TOKEN: ${{ secrets.BOT_PAT }}
@@ -109,7 +140,7 @@ jobs:
fi
- name: Fail if baselines changed
if: steps.commit-baselines.outputs.changed == 'true'
if: needs.check-paths.outputs.is_fork != 'true' && steps.commit-baselines.outputs.changed == 'true'
run: |
echo "::error::Visual regression baselines changed. New baselines have been committed to the branch. Please pull and review."
exit 1
@@ -130,13 +161,20 @@ jobs:
timeout-minutes: 15
steps:
- name: Checkout
- name: Checkout (internal)
if: needs.check-paths.outputs.is_fork != 'true'
uses: actions/checkout@v4
with:
lfs: true
token: ${{ secrets.BOT_PAT }}
ref: ${{ github.head_ref }}
- name: Checkout (fork)
if: needs.check-paths.outputs.is_fork == 'true'
uses: actions/checkout@v4
with:
lfs: true
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
@@ -186,7 +224,22 @@ jobs:
CI: true
PLAYWRIGHT_WORKERS: "4"
- name: Check for baseline changes (fork PRs)
if: needs.check-paths.outputs.is_fork == 'true'
run: |
git add packages/kilo-vscode/tests/visual-regression.spec.ts-snapshots/
if git diff --cached --quiet; then
echo "No visual regression detected."
else
echo "::error::Visual regression detected. Screenshot baselines have changed."
echo "::error::Since this PR is from a fork, updated screenshots cannot be committed automatically."
echo "::error::Please update your screenshots locally by running 'bun run test:visual:update' in packages/kilo-vscode/ and commit the results."
git diff --cached --stat
exit 1
fi
- name: Commit and push new baselines (if any)
if: needs.check-paths.outputs.is_fork != 'true'
id: commit-baselines-vscode
env:
GH_TOKEN: ${{ secrets.BOT_PAT }}
@@ -205,7 +258,7 @@ jobs:
fi
- name: Fail if baselines changed
if: steps.commit-baselines-vscode.outputs.changed == 'true'
if: needs.check-paths.outputs.is_fork != 'true' && steps.commit-baselines-vscode.outputs.changed == 'true'
run: |
echo "::error::Visual regression baselines changed. New baselines have been committed to the branch. Please pull and review."
exit 1