-
Notifications
You must be signed in to change notification settings - Fork 7
53 lines (46 loc) · 1.49 KB
/
pkg-pr-new.yaml
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
name: Publish Approved Pull Requests to pkg.pr.new
on:
pull_request_review:
types: [submitted]
permissions:
contents: read
pull-requests: read
jobs:
check:
# First, trigger a permissions check on the user approving the pull request.
if: github.event.review.state == 'approved'
runs-on: ubuntu-latest
outputs:
has-permissions: ${{ steps.checkPermissions.outputs.result }}
steps:
- name: Check permissions
id: checkPermissions
uses: actions/github-script@v7
with:
result-encoding: string
# The approver must have write access to the repository to trigger the package preview.
script: |
const { data: { permission } } =
await github.rest.repos.getCollaboratorPermissionLevel({
...context.repo,
username: context.actor,
});
return permission === 'write' || permission === 'admin';
publish:
needs: check
# Publish the preview package only if the permissions check passed.
if: needs.check.outputs.has-permissions == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: 22
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm exec turbo build
- run: pnpm dlx pkg-pr-new publish './packages/*'