Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/schema-regen-changeset-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'scope3': patch
---

Ensure schema regeneration PRs include a changeset and require new changesets in every non-release PR
33 changes: 16 additions & 17 deletions .github/workflows/changeset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,27 @@ jobs:
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '20'

- name: Install dependencies
run: npm ci

- name: Check for changeset
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_REF: ${{ github.head_ref }}
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
# Skip changeset check for release PRs created by changesets/action
if [[ "${{ github.head_ref }}" == changeset-release/* ]] || [[ "${{ github.event.pull_request.title }}" == "chore: version packages" ]]; then
echo "⏭️ Skipping changeset check for release PR"
if [[ "$HEAD_REF" == changeset-release/* ]] || [[ "$PR_TITLE" == "chore: version packages" ]]; then
echo "Skipping changeset check for release PR"
exit 0
fi

if [ -z "$(ls -A .changeset/*.md 2>/dev/null | grep -v README)" ]; then
echo "❌ No changeset found. Please add a changeset by running 'npm run changeset'"
NEW_CHANGESETS=$(git diff --name-only --diff-filter=A "$BASE_SHA...HEAD" -- '.changeset/*.md' | grep -v 'README\.md' || true)

if [ -z "$NEW_CHANGESETS" ]; then
echo "No new changeset found in this PR."
echo ""
echo "Changesets help track version changes and generate changelogs."
echo "Run 'npm run changeset' and follow the prompts to create one."
echo "Every PR must add a changeset file to .changeset/."
echo "Run 'npm run changeset' to create one describing your change."
echo "If no version bump is needed, run 'npx changeset --empty'."
exit 1
else
echo "✅ Changeset found"
fi

echo "New changeset(s) added in this PR:"
echo "$NEW_CHANGESETS"
15 changes: 13 additions & 2 deletions .github/workflows/regenerate-schemas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,24 @@ jobs:
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
BRANCH="chore/regenerate-schemas-$(date +%Y%m%d-%H%M%S)"
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
BRANCH="chore/regenerate-schemas-${TIMESTAMP}"
CHANGESET_FILE=".changeset/regenerate-schemas-${TIMESTAMP}.md"

git config user.name "scope3-wizard[bot]"
git config user.email "${{ vars.SCOPE3_WIZARD_APP_ID }}+scope3-wizard[bot]@users.noreply.github.com"

git checkout -b "$BRANCH"
git add src/schemas/

cat > "$CHANGESET_FILE" <<'EOF'
---
'scope3': minor
---

Regenerate Zod schemas from the latest OpenAPI specification
EOF

git add src/schemas/ "$CHANGESET_FILE"
git commit -m "chore: regenerate schemas from OpenAPI spec"
git push origin "$BRANCH"

Expand Down