@@ -33,122 +33,23 @@ jobs:
3333 - name : Publish library
3434 run : npx pkg-pr-new publish --no-template --json output.json --comment=off
3535
36+ - name : Include PR info in output file
37+ uses : actions/github-script@v8
38+ env :
39+ PR_NUMBER : ${{ github.event.pull_request.number }}
40+ with :
41+ script : |
42+ const fs = require('fs');
43+ const output = JSON.parse(fs.readFileSync('output.json', 'utf8'));
44+ output.workflow = {
45+ pull_request: process.env.PR_NUMBER ? {
46+ number: process.env.PR_NUMBER
47+ } : null
48+ };
49+ fs.writeFileSync('output.json', JSON.stringify(output));
50+
3651 - name : Upload output data
3752 uses : actions/upload-artifact@v4
3853 with :
3954 name : output.json
40- path : output.json
41-
42- # - name: Post or update comment
43- # uses: actions/github-script@v8
44- # with:
45- # github-token: ${{ secrets.ACCESS_TOKEN }}
46- # script: |
47- # const fs = require('fs');
48- # const output = JSON.parse(fs.readFileSync('output.json', 'utf8'));
49-
50- # const packages = output.packages
51- # .map((p) => `- ${p.name}: ${p.url}`)
52- # .join('\n');
53-
54- # const cdnLinks = output.packages
55- # .map((p) => `- ${p.name}: https://raw.esm.sh/pr/p5@${p.sha}/lib/p5.min.js`)
56- # .join('\n');
57-
58- # const sha =
59- # context.event_name === 'pull_request'
60- # ? context.payload.pull_request.head.sha
61- # : context.payload.after;
62-
63- # const commitUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/commit/${sha}`;
64-
65- # const body = `## Continuous Release
66-
67- # ### CDN link
68-
69- # ${cdnLinks}
70-
71- # ### Published Packages:
72-
73- # ${packages}
74-
75- # [View Commit](${commitUrl})
76-
77- # ---
78-
79- # _This is an automated message._`;
80-
81- # const botCommentIdentifier = '## Continuous Release';
82-
83- # async function findBotComment(issueNumber) {
84- # if (!issueNumber) return null;
85- # const comments = await github.rest.issues.listComments({
86- # owner: context.repo.owner,
87- # repo: context.repo.repo,
88- # issue_number: issueNumber,
89- # });
90- # return comments.data.find((comment) =>
91- # comment.body.includes(botCommentIdentifier)
92- # );
93- # }
94-
95- # async function createOrUpdateComment(issueNumber) {
96- # if (!issueNumber) {
97- # console.log('No issue number provided. Cannot post or update comment.');
98- # return;
99- # }
100-
101- # const existingComment = await findBotComment(issueNumber);
102- # if (existingComment) {
103- # await github.rest.issues.updateComment({
104- # owner: context.repo.owner,
105- # repo: context.repo.repo,
106- # comment_id: existingComment.id,
107- # body: body,
108- # });
109- # } else {
110- # await github.rest.issues.createComment({
111- # issue_number: issueNumber,
112- # owner: context.repo.owner,
113- # repo: context.repo.repo,
114- # body: body,
115- # });
116- # }
117- # }
118-
119- # async function logPublishInfo() {
120- # console.log('\n' + '='.repeat(50));
121- # console.log('Publish Information');
122- # console.log('='.repeat(50));
123- # console.log('\nPublished Packages:');
124- # console.log(packages);
125- # console.log('\nTemplates:');
126- # console.log(templates);
127- # console.log(`\nCommit URL: ${commitUrl}`);
128- # console.log('\n' + '='.repeat(50));
129- # }
130-
131- # if (context.eventName === 'pull_request') {
132- # if (context.issue.number) {
133- # await createOrUpdateComment(context.issue.number);
134- # }
135- # } else if (context.eventName === 'push') {
136- # const pullRequests = await github.rest.pulls.list({
137- # owner: context.repo.owner,
138- # repo: context.repo.repo,
139- # state: 'open',
140- # head: `${context.repo.owner}:${context.ref.replace(
141- # 'refs/heads/',
142- # ''
143- # )}`,
144- # });
145-
146- # if (pullRequests.data.length > 0) {
147- # await createOrUpdateComment(pullRequests.data[0].number);
148- # } else {
149- # console.log(
150- # 'No open pull request found for this push. Logging publish information to console:'
151- # );
152- # await logPublishInfo();
153- # }
154- # }
55+ path : output.json
0 commit comments