Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: setup pkg.pr.new #271

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/workflows/publish-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Publishes main-branch's commits to pkg.pr.new
# PRs can be published by commenting `/pkg-pr-new` in the PR

name: Publish Any Commit

on:
push:
branches:
- main
issue_comment:
types: [created]

jobs:
build:
if: github.repository == 'stackblitz/tutorialkit' && (github.event_name == 'push' || github.event.issue.pull_request && startsWith(github.event.comment.body, '/pkg-pr-new'))
runs-on: ubuntu-latest

steps:
- if: github.event.issue.pull_request
uses: actions/github-script@v7
with:
script: |
const user = context.payload.sender.login
console.log(`Validate user: ${user}`)

let hasTriagePermission = false
try {
const { data } = await github.rest.repos.getCollaboratorPermissionLevel({
owner: context.repo.owner,
repo: context.repo.repo,
username: user,
});
hasTriagePermission = data.user.permissions.triage
} catch (e) {
console.warn(e)
}

if (hasTriagePermission) {
console.log('Allowed')
await github.rest.reactions.createForIssueComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: context.payload.comment.id,
content: '+1',
})
} else {
console.log('Not allowed')
await github.rest.reactions.createForIssueComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: context.payload.comment.id,
content: '-1',
})
throw new Error('not allowed')
}

- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: ./.github/actions/setup-and-build

- name: Publish to pkg.pr.new
run: >
pnpm dlx [email protected] publish --compact --pnpm
./packages/astro
./packages/components/react
./packages/runtime
./packages/theme
./packages/types
AriPerkkio marked this conversation as resolved.
Show resolved Hide resolved