Skip to content
Closed
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/arpit-bruno-patch-1-test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@opencollection/docs": minor
---

test: changeset label action (#1)
52 changes: 52 additions & 0 deletions .github/workflows/changeset.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Changeset

on:
pull_request:
types: [labeled]

jobs:
changeset:
if: startsWith(github.event.label.name, 'changeset:')
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}

- name: Write the changeset
env:
LABEL: ${{ github.event.label.name }}
TITLE: ${{ github.event.pull_request.title }}
BRANCH: ${{ github.event.pull_request.head.ref }}
NUMBER: ${{ github.event.pull_request.number }}
run: |
bump="${LABEL#changeset:}"
slug=$(printf '%s' "$BRANCH" \
| tr '[:upper:]' '[:lower:]' \
| sed -e 's#[^a-z0-9]#-#g' -e 's#--*#-#g' -e 's#^-##' -e 's#-$##')

mkdir -p .changeset
printf -- '---\n"@opencollection/docs": %s\n---\n\n%s (#%s)\n' \
"$bump" "$TITLE" "$NUMBER" > ".changeset/${slug}.md"

cat ".changeset/${slug}.md"

- name: Commit it to the PR branch
env:
ACTOR: ${{ github.actor }}
ACTOR_ID: ${{ github.actor_id }}
run: |
git config user.name "$ACTOR"
git config user.email "${ACTOR_ID}+${ACTOR}@users.noreply.github.com"
git add .changeset
if git diff --cached --quiet; then
echo "changeset unchanged, nothing to commit"
exit 0
fi
git commit -m "chore: add changeset"
git push

Loading