Skip to content

Commit

Permalink
ci: add publish-by-comment
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio committed Aug 26, 2024
1 parent 9588705 commit 29b6665
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/publish-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# 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 == 'AriPerkkio/eslint-remote-tester' && (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')
}
- uses: actions/checkout@v4

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

- name: Install & Build
run: |
pnpm install
pnpm build
- name: Publish to pkg.pr.new
run: >
pnpm dlx [email protected] publish --compact --pnpm
./packages/eslint-remote-tester
./packages/repositories

0 comments on commit 29b6665

Please sign in to comment.