Skip to content

Commit c7155c3

Browse files
authored
chore: update pkg.pr.new workflow (#1055)
1 parent 7c0dc31 commit c7155c3

File tree

2 files changed

+43
-7
lines changed

2 files changed

+43
-7
lines changed

Diff for: .github/workflows/pkg.pr.new-comment.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Update pkg.pr.new comment
2+
3+
on:
4+
workflow_run:
5+
workflows: ['Publish to pkg.pr.new']
6+
types:
7+
- completed
8+
9+
jobs:
10+
build:
11+
if: github.repository == 'sveltejs/eslint-plugin-svelte'
12+
name: 'Update comment'
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Download artifact
16+
uses: actions/download-artifact@v4
17+
with:
18+
name: output
19+
github-token: ${{ secrets.GITHUB_TOKEN }}
20+
run-id: ${{ github.event.workflow_run.id }}
21+
- run: ls -R .
22+
- name: 'Post or update comment'
23+
uses: actions/github-script@v6
24+
with:
25+
github-token: ${{ secrets.GITHUB_TOKEN }}
26+
script: |
27+
const fs = require('fs');
28+
const output = JSON.parse(fs.readFileSync('output.json', 'utf8'));
29+
const { default: process } = await import('${{ github.workspace }}/tools/pkg.pr.new-comment.mjs')
30+
31+
await process({github, context, core, output})

Diff for: .github/workflows/pkg.pr.new.yml

+12-7
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ on:
66
branches: [main]
77
tags: ['!**']
88

9-
permissions:
10-
issues: write
11-
pull-requests: write
12-
139
jobs:
1410
build:
1511
if: github.repository == 'sveltejs/eslint-plugin-svelte'
@@ -24,12 +20,21 @@ jobs:
2420
- name: Build
2521
run: pnpm run build
2622
- run: pnpx pkg-pr-new publish --compact './packages/eslint-plugin-svelte' --json output.json --comment=off
27-
- uses: actions/github-script@v7
23+
- name: Add metadata to output
24+
uses: actions/github-script@v7
2825
with:
2926
github-token: ${{ secrets.GITHUB_TOKEN }}
3027
script: |
3128
const fs = require('fs');
3229
const output = JSON.parse(fs.readFileSync('output.json', 'utf8'));
33-
const { default: process } = await import('${{ github.workspace }}/tools/pkg.pr.new-comment.mjs')
30+
output.number = context.issue.number;
31+
output.event_name = context.eventName;
32+
output.ref = context.ref;
33+
fs.writeFileSync('output.json', JSON.stringify(output), 'utf8');
34+
- name: Upload output
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: output
38+
path: ./output.json
3439

35-
await process({github, context, core, output})
40+
- run: ls -R .

0 commit comments

Comments
 (0)