Skip to content

Commit aad1e51

Browse files
committed
chore: add early bump-plan step to skip snapshot checks on minor/major
1 parent 63b2c4e commit aad1e51

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

.github/workflows/pull-request-snapshot-diff.yml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,35 @@ jobs:
4646
git fetch --no-tags --prune origin +refs/heads/main:refs/remotes/origin/main
4747
git rev-parse remotes/origin/main >/dev/null
4848
49+
# Early scan of changed .changeset/*.md files for 'minor'/'major'.
50+
- name: 🔎 Early bump plan (fallback-only for skip)
51+
id: early_plan
52+
shell: bash
53+
run: |
54+
set -euo pipefail
55+
HAS_MINOR=0
56+
HAS_MAJOR=0
57+
58+
git diff --name-only origin/main...HEAD -- ".changeset/*.md" > .cs-files || true
59+
60+
if [ -s .cs-files ]; then
61+
while read -r f; do
62+
[ -z "${f:-}" ] && continue
63+
grep -qE ':\s*minor\b' "$f" && HAS_MINOR=1 || true
64+
grep -qE ':\s*major\b' "$f" && HAS_MAJOR=1 || true
65+
done < .cs-files
66+
fi
67+
68+
{
69+
echo "HAS_MINOR=${HAS_MINOR}"
70+
echo "HAS_MAJOR=${HAS_MAJOR}"
71+
} >> "$GITHUB_ENV"
72+
4973
# Compute unified diff + name-status for PNG/YML snapshot files.
5074
# Build a Markdown summary and export counters via $GITHUB_ENV.
5175
- name: 🧾 Collect changed PNG/YML snapshots
5276
id: diff
77+
if: env.HAS_MINOR == '0' && env.HAS_MAJOR == '0'
5378
shell: bash
5479
run: |
5580
set -euo pipefail
@@ -106,7 +131,7 @@ jobs:
106131
107132
# Attach the full unified diff as a downloadable artifact if there are changes.
108133
- name: 📎 Upload unified diff (artifact)
109-
if: env.SNAP_TOTAL != '0'
134+
if: env.HAS_MINOR == '0' && env.HAS_MAJOR == '0' && env.SNAP_TOTAL && env.SNAP_TOTAL != '0'
110135
uses: actions/upload-artifact@v4
111136
with:
112137
name: snapshots-diff
@@ -116,6 +141,7 @@ jobs:
116141

117142
# Post (or update) a PR comment with the table summary.
118143
- name: 💬 Upsert PR comment
144+
if: env.HAS_MINOR == '0' && env.HAS_MAJOR == '0'
119145
uses: actions/github-script@v7
120146
env:
121147
SNAP_SUMMARY_MD_PATH: ${{ env.SNAP_SUMMARY_MD_PATH }}
@@ -199,7 +225,7 @@ jobs:
199225
# Guardrail: if snapshots changed, require at least MINOR (or MAJOR).
200226
# This prevents accidental PATCH releases for visual/markup-impacting changes.
201227
- name: 🚦 Enforce Snapshot changes require >= minor
202-
if: env.SNAP_TOTAL != '0'
228+
if: env.HAS_MINOR == '0' && env.HAS_MAJOR == '0' && env.SNAP_TOTAL && env.SNAP_TOTAL != '0'
203229
shell: bash
204230
run: |
205231
set -euo pipefail

0 commit comments

Comments
 (0)