|
1 |
| -# PRs can be published by commenting `/pkg-pr-new` in the PR |
| 1 | +# PRs can be published by adding `pkg-pr-new` tag |
2 | 2 |
|
3 |
| -name: Publish Any Commit |
| 3 | +name: PR Preview Releases |
4 | 4 |
|
5 | 5 | on:
|
6 |
| - issue_comment: |
7 |
| - types: [created] |
| 6 | + push: |
| 7 | + branches: [main] |
| 8 | + pull_request: |
| 9 | + types: [opened, synchronize, labeled] |
8 | 10 |
|
9 | 11 | jobs:
|
10 |
| - build: |
11 |
| - if: github.repository == 'stackblitz/tutorialkit' && (github.event_name == 'push' || github.event.issue.pull_request && startsWith(github.event.comment.body, '/pkg-pr-new')) |
| 12 | + release: |
| 13 | + if: github.repository == 'stackblitz/tutorialkit' && (github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'pkg-pr-new')) |
12 | 14 | runs-on: ubuntu-latest
|
| 15 | + name: 'Release: pkg.pr.new' |
13 | 16 |
|
14 | 17 | steps:
|
15 |
| - - if: github.event.issue.pull_request |
16 |
| - uses: actions/github-script@v7 |
17 |
| - with: |
18 |
| - script: | |
19 |
| - const user = context.payload.sender.login |
20 |
| - console.log(`Validate user: ${user}`) |
21 |
| -
|
22 |
| - let hasTriagePermission = false |
23 |
| - try { |
24 |
| - const { data } = await github.rest.repos.getCollaboratorPermissionLevel({ |
25 |
| - owner: context.repo.owner, |
26 |
| - repo: context.repo.repo, |
27 |
| - username: user, |
28 |
| - }); |
29 |
| - hasTriagePermission = data.user.permissions.triage |
30 |
| - } catch (e) { |
31 |
| - console.warn(e) |
32 |
| - } |
33 |
| -
|
34 |
| - if (hasTriagePermission) { |
35 |
| - console.log('Allowed') |
36 |
| - await github.rest.reactions.createForIssueComment({ |
37 |
| - owner: context.repo.owner, |
38 |
| - repo: context.repo.repo, |
39 |
| - comment_id: context.payload.comment.id, |
40 |
| - content: '+1', |
41 |
| - }) |
42 |
| - } else { |
43 |
| - console.log('Not allowed') |
44 |
| - await github.rest.reactions.createForIssueComment({ |
45 |
| - owner: context.repo.owner, |
46 |
| - repo: context.repo.repo, |
47 |
| - comment_id: context.payload.comment.id, |
48 |
| - content: '-1', |
49 |
| - }) |
50 |
| - throw new Error('not allowed') |
51 |
| - } |
52 |
| -
|
53 | 18 | - name: Checkout
|
54 | 19 | uses: actions/checkout@v4
|
55 | 20 | with:
|
56 |
| - ref: refs/pull/${{ github.event.issue.number }}/head |
| 21 | + fetch-depth: 0 |
57 | 22 |
|
58 | 23 | - uses: ./.github/actions/setup-and-build
|
59 | 24 |
|
|
0 commit comments