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
53 changes: 43 additions & 10 deletions .github/workflows/dependabot-changeset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,49 @@ name: Dependabot Changeset
on:
pull_request:
types: [opened, reopened]
workflow_dispatch:

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

- name: Get PR info
id: pr
env:
GH_TOKEN: ${{ github.token }}
run: |
echo "number=$(gh pr view --json number --jq '.number')" >> "$GITHUB_OUTPUT"
echo "title=$(gh pr view --json title --jq '.title')" >> "$GITHUB_OUTPUT"

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10.33.0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '24'
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --no-frozen-lockfile

- name: Check for existing changeset
id: check
run: |
filename=".changeset/dependabot-pr-${{ github.event.pull_request.number }}.md"
filename=".changeset/dependabot-pr-${{ steps.pr.outputs.number }}.md"
if [ -f "$filename" ]; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
Expand All @@ -31,16 +55,25 @@ jobs:
- name: Create changeset
if: steps.check.outputs.exists == 'false'
env:
PR_TITLE: ${{ github.event.pull_request.title }}
PR_TITLE: ${{ steps.pr.outputs.title }}
run: |
filename=".changeset/dependabot-pr-${{ github.event.pull_request.number }}.md"
filename=".changeset/dependabot-pr-${{ steps.pr.outputs.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'
- name: Commit and push
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
CHANGED=false
if [ -n "$(git status --porcelain pnpm-lock.yaml)" ]; then
git add pnpm-lock.yaml
CHANGED=true
fi
if [ "${{ steps.check.outputs.exists }}" == 'false' ]; then
git add ".changeset/dependabot-pr-${{ steps.pr.outputs.number }}.md"
CHANGED=true
fi
if [ "$CHANGED" = true ]; then
git commit -m "chore: add changeset and update lockfile for dependabot PR #${{ steps.pr.outputs.number }}"
git push
fi
Loading