Skip to content
Merged
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
46 changes: 46 additions & 0 deletions .github/workflows/dependabot-changeset.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Dependabot Changeset

on:
pull_request:
types: [opened, reopened]

jobs:
add-changeset:
name: Add Changeset
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
fetch-depth: 0

- name: Check for existing changeset
id: check
run: |
filename=".changeset/dependabot-pr-${{ github.event.pull_request.number }}.md"
if [ -f "$filename" ]; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
Comment on lines +21 to +29
Copy link

Copilot AI Apr 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "Check for existing changeset" step is checking whether any .changeset/*.md file exists in the repo, which will be true on branches created from main (this repo already contains many changesets). As a result, exists will almost always be true and the workflow will never create a changeset for Dependabot PRs.

Instead, detect whether the PR introduces a changeset relative to the base branch (e.g. reuse the same logic as CI: pnpm exec changeset status --since origin/${{ github.base_ref }}), or at least check for the presence of the specific file you intend to create (.changeset/dependabot-pr-<number>.md).

Copilot uses AI. Check for mistakes.

- name: Create changeset
if: steps.check.outputs.exists == 'false'
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
filename=".changeset/dependabot-pr-${{ github.event.pull_request.number }}.md"
printf -- '---\n"nostream": patch\n---\n\n%s\n' "$PR_TITLE" > "$filename"

- name: Commit and push changeset
if: steps.check.outputs.exists == 'false'
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add .changeset/dependabot-pr-${{ github.event.pull_request.number }}.md
git commit -m "chore: add changeset for dependabot PR #${{ github.event.pull_request.number }}"
git push
Loading