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