-
-
Notifications
You must be signed in to change notification settings - Fork 28
69 lines (57 loc) · 1.9 KB
/
comment-release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: release
permissions:
contents: write
on:
issue_comment:
types:
- created
jobs:
release:
if: ${{ github.event.issue.pull_request && github.event.comment.body == 'npm publish' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: ⬇️ Checkout PR
run: |
git fetch origin pull/${{ github.event.issue.number }}/head:pr-find-commit
git checkout pr-find-commit
- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: 9
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"
registry-url: "https://registry.npmjs.org"
- name: npm version
run: npm version --no-git-tag-version 0.0.0-$(git rev-parse HEAD)
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Install dependencies
run: pnpm install
# publish to npm tag as next
- run: pnpm publish --no-git-checks --tag pre
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: "Update comment"
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { issue: { number: issue_number }, repo: { owner, repo }, payload } = context;
const { name: packageName, version } = require(`${process.env.GITHUB_WORKSPACE}/package.json`);
const body = [
`npm package published to pre tag.`,
`\`\`\`bash\nnpm install ${packageName}@pre\n\`\`\``
`\`\`\`bash\nnpm install ${packageName}@${version}\n\`\`\``
].join('\n\n');
await github.rest.issues.updateComment({
owner,
repo,
comment_id: payload.comment.id,
body,
});