Skip to content

Commit

Permalink
ci: preview releases by PR tags
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio committed Nov 25, 2024
1 parent 2740bc9 commit 48188ce
Showing 1 changed file with 9 additions and 44 deletions.
53 changes: 9 additions & 44 deletions .github/workflows/publish-commit.yaml
Original file line number Diff line number Diff line change
@@ -1,55 +1,20 @@
# PRs can be published by commenting `/pkg-pr-new` in the PR
# PRs can be published by adding `pkg-pr-new` tag

name: Publish Any Commit
name: PR Preview Releases

on:
issue_comment:
types: [created]
push:
branches: [main]
pull_request:
types: [opened, synchronize, labeled]

jobs:
build:
if: github.repository == 'stackblitz/tutorialkit' && (github.event_name == 'push' || github.event.issue.pull_request && startsWith(github.event.comment.body, '/pkg-pr-new'))
release:
if: github.repository == 'stackblitz/tutorialkit' && (github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'pkg-pr-new'))
runs-on: ubuntu-latest
name: 'Release: pkg.pr.new'

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:
Expand Down

0 comments on commit 48188ce

Please sign in to comment.