|
| 1 | +# Publishes main-branch's commits to pkg.pr.new |
| 2 | +# PRs can be published by commenting `/pkg-pr-new` in the PR |
| 3 | + |
| 4 | +name: Publish Any Commit |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + issue_comment: |
| 11 | + types: [created] |
| 12 | + |
| 13 | +jobs: |
| 14 | + build: |
| 15 | + if: github.repository == 'stackblitz/tutorialkit' && (github.event_name == 'push' || github.event.issue.pull_request && startsWith(github.event.comment.body, '/pkg-pr-new')) |
| 16 | + runs-on: ubuntu-latest |
| 17 | + |
| 18 | + steps: |
| 19 | + - if: github.event.issue.pull_request |
| 20 | + uses: actions/github-script@v7 |
| 21 | + with: |
| 22 | + script: | |
| 23 | + const user = context.payload.sender.login |
| 24 | + console.log(`Validate user: ${user}`) |
| 25 | +
|
| 26 | + let hasTriagePermission = false |
| 27 | + try { |
| 28 | + const { data } = await github.rest.repos.getCollaboratorPermissionLevel({ |
| 29 | + owner: context.repo.owner, |
| 30 | + repo: context.repo.repo, |
| 31 | + username: user, |
| 32 | + }); |
| 33 | + hasTriagePermission = data.user.permissions.triage |
| 34 | + } catch (e) { |
| 35 | + console.warn(e) |
| 36 | + } |
| 37 | +
|
| 38 | + if (hasTriagePermission) { |
| 39 | + console.log('Allowed') |
| 40 | + await github.rest.reactions.createForIssueComment({ |
| 41 | + owner: context.repo.owner, |
| 42 | + repo: context.repo.repo, |
| 43 | + comment_id: context.payload.comment.id, |
| 44 | + content: '+1', |
| 45 | + }) |
| 46 | + } else { |
| 47 | + console.log('Not allowed') |
| 48 | + await github.rest.reactions.createForIssueComment({ |
| 49 | + owner: context.repo.owner, |
| 50 | + repo: context.repo.repo, |
| 51 | + comment_id: context.payload.comment.id, |
| 52 | + content: '-1', |
| 53 | + }) |
| 54 | + throw new Error('not allowed') |
| 55 | + } |
| 56 | +
|
| 57 | + - name: Checkout |
| 58 | + uses: actions/checkout@v4 |
| 59 | + with: |
| 60 | + fetch-depth: 0 |
| 61 | + |
| 62 | + - uses: ./.github/actions/setup-and-build |
| 63 | + |
| 64 | + - name: Publish to pkg.pr.new |
| 65 | + run: > |
| 66 | + pnpm dlx [email protected] publish --compact --pnpm |
| 67 | + ./packages/astro |
| 68 | + ./packages/components/react |
| 69 | + ./packages/runtime |
| 70 | + ./packages/theme |
| 71 | + ./packages/types |
0 commit comments