Skip to content

Commit 1ad84ac

Browse files
authored
ci: preview releases by PR tags (#424)
1 parent 2740bc9 commit 1ad84ac

File tree

1 file changed

+10
-45
lines changed

1 file changed

+10
-45
lines changed

.github/workflows/publish-commit.yaml

+10-45
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,24 @@
1-
# PRs can be published by commenting `/pkg-pr-new` in the PR
1+
# PRs can be published by adding `pkg-pr-new` tag
22

3-
name: Publish Any Commit
3+
name: PR Preview Releases
44

55
on:
6-
issue_comment:
7-
types: [created]
6+
push:
7+
branches: [main]
8+
pull_request:
9+
types: [opened, synchronize, labeled]
810

911
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'))
1214
runs-on: ubuntu-latest
15+
name: 'Release: pkg.pr.new'
1316

1417
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-
5318
- name: Checkout
5419
uses: actions/checkout@v4
5520
with:
56-
ref: refs/pull/${{ github.event.issue.number }}/head
21+
fetch-depth: 0
5722

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

0 commit comments

Comments
 (0)