-
Notifications
You must be signed in to change notification settings - Fork 266
107 lines (98 loc) · 3.47 KB
/
pkg.pr.new.yml
File metadata and controls
107 lines (98 loc) · 3.47 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: Publish to pkg.pr.new
on:
push:
branches: [main, develop]
tags: ["!**"]
paths: ["packages/**"]
pull_request:
types: [opened, synchronize]
paths: ["packages/**"]
pull_request_review:
types: [submitted]
workflow_dispatch:
jobs:
approval-check:
name: Check for Collaborator Approval
# Github doesn't support conditional needs, so this needs to run no matter what. :')
# if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
outputs:
is-approved: ${{ steps.check_for_approval.outputs.collaborator-approved }}
steps:
- name: Check for approval by a collaborator
id: check-for-approval
uses: actions/github-script@v8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
const pr = context.payload.pull_request;
if (!pr) {
// This can happen on events that don't have a PR context.
return 'false';
}
const reviews = await github.rest.pulls.listReviews({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr.number
});
const isApproved = reviews.data.some(review =>
review.state === 'APPROVED' &&
['MEMBER', 'OWNER', 'COLLABORATOR'].includes(review.author_association)
);
console.log(`PR is approved by collaborator: ${isApproved}`);
return isApproved.toString();
publish:
# Only run if pushed to main, is a PR by a collaborator,
# or an external PR approved by a collaborator.
needs: approval-check
if: >-
(github.event_name == 'push') ||
(github.event_name == 'pull_request' && (
github.event.pull_request.author_association == 'MEMBER' ||
github.event.pull_request.author_association == 'OWNER' ||
github.event.pull_request.author_association == 'COLLABORATOR'
)) ||
(needs.approval-check.outputs.approved == 'true') ||
(github.event_name == 'pull_request_review' &&
github.event.review.state == 'approved' && (
github.event.review.author_association == 'MEMBER' ||
github.event.review.author_association == 'OWNER' ||
github.event.review.author_association == 'COLLABORATOR'
))
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
cache: "pnpm"
- name: Install dependencies
run: pnpm install --prod false --frozen-lockfile
- name: Build cli
working-directory: ./packages/cli
run: pnpm build
- name: Publish
run: |
pnpm dlx pkg-pr-new publish \
'./packages/eslint-plugin' \
'./packages/eslint-parser' \
'./packages/typescript-plugin' \
'./packages/create-ripple' \
'./packages/prettier-plugin' \
'./packages/ripple' \
'./packages/adapter' \
'./packages/adapter-node' \
'./packages/adapter-bun' \
'./packages/rollup-plugin' \
'./packages/vite-plugin' \
'./packages/cli' \
--compact \
--comment=update \
--packageManager=pnpm \
--pnpm \
--template './templates/basic'