Skip to content

Commit dbf142f

Browse files
github actions: switch embedded JS to ESM (#3612)
1 parent 4970a92 commit dbf142f

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

.github/workflows/cmd-publish-pr-on-npm.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ jobs:
6666
uses: actions/github-script@v5
6767
with:
6868
script: |
69-
const fs = require('fs');
70-
const assert = require('assert');
69+
import fs from 'node:fs';
70+
import assert from 'node:assert';
7171
7272
const pull_request = JSON.parse(process.env.PULL_REQUEST_JSON);
7373
const packageJSONPath = './npmDist/package.json';

.github/workflows/cmd-run-benchmark.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
uses: actions/github-script@v5
3939
with:
4040
script: |
41-
const fs = require('fs');
41+
import fs from 'node:fs';
4242
4343
// GH doesn't expose job's id so we need to get it through API, see
4444
// https://i.8713187.xyzmunity/t/job-id-is-string-in-github-job-but-integer-in-actions-api/139060

.github/workflows/github-actions-bot.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ jobs:
3737
uses: actions/github-script@v5
3838
with:
3939
script: |
40-
const fs = require('fs');
40+
import fs from 'node:fs';
4141
4242
const event = JSON.parse(fs.readFileSync('./event.json', 'utf8'));
43-
github.rest.issues.createComment({
43+
await github.rest.issues.createComment({
4444
...context.repo,
4545
issue_number: event.pull_request.number,
4646
body:
@@ -61,7 +61,7 @@ jobs:
6161
- uses: actions/github-script@v5
6262
with:
6363
script: |
64-
github.rest.reactions.createForIssueComment({
64+
await github.rest.reactions.createForIssueComment({
6565
...context.repo,
6666
comment_id: context.payload.comment.id,
6767
content: 'eyes',
@@ -110,7 +110,7 @@ jobs:
110110
uses: actions/github-script@v5
111111
with:
112112
script: |
113-
const fs = require('fs');
113+
import fs from 'node:fs';
114114
115115
const needs = JSON.parse(process.env.NEEDS);
116116
@@ -134,7 +134,7 @@ jobs:
134134
uses: actions/github-script@v5
135135
with:
136136
script: |
137-
const fs = require('fs');
137+
import fs from 'node:fs';
138138
139139
const replyMessage = fs.readFileSync('./replyMessage.txt', 'utf-8');
140140
const { issue, comment, sender } = context.payload;
@@ -144,14 +144,14 @@ jobs:
144144
.map((line) => '> ' + line)
145145
.join('\n');
146146
147-
github.rest.issues.createComment({
147+
await github.rest.issues.createComment({
148148
...context.repo,
149149
issue_number: issue.number,
150150
body: quoteRequest + `\n\n@${sender.login} ` + replyMessage,
151151
});
152152
153153
// `github.rest` doesn't have this method :( so use graphql instead
154-
github.graphql(`
154+
await github.graphql(`
155155
mutation ($subjectId: ID!) {
156156
minimizeComment(input: { subjectId: $subjectId, classifier: RESOLVED})
157157
{ __typename }

0 commit comments

Comments
 (0)