forked from cameri/nostream
-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (78 loc) · 2.88 KB
/
Copy pathdependabot-changeset.yml
File metadata and controls
87 lines (78 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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]' || github.event_name == 'workflow_dispatch'
permissions:
contents: write
pull-requests: read
steps:
- name: Checkout
uses: actions/checkout@v3
with:
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-${{ steps.pr.outputs.number }}.md"
if [ -f "$filename" ]; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
- name: Create changeset
if: steps.check.outputs.exists == 'false'
env:
PR_TITLE: ${{ steps.pr.outputs.title }}
run: |
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
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
ADDED_CHANGESET=false
ADDED_LOCKFILE=false
if [ "${{ steps.check.outputs.exists }}" == 'false' ]; then
git add ".changeset/dependabot-pr-${{ steps.pr.outputs.number }}.md"
ADDED_CHANGESET=true
fi
if [ -n "$(git status --porcelain pnpm-lock.yaml)" ]; then
git add pnpm-lock.yaml
ADDED_LOCKFILE=true
fi
if [ "$ADDED_CHANGESET" = true ] || [ "$ADDED_LOCKFILE" = true ]; then
if [ "$ADDED_CHANGESET" = true ] && [ "$ADDED_LOCKFILE" = true ]; then
MSG="chore: add changeset and update lockfile for dependabot PR #${{ steps.pr.outputs.number }}"
elif [ "$ADDED_CHANGESET" = true ]; then
MSG="chore: add changeset for dependabot PR #${{ steps.pr.outputs.number }}"
else
MSG="chore: update lockfile for dependabot PR #${{ steps.pr.outputs.number }}"
fi
git commit -m "$MSG"
git push
fi