Skip to content

Commit 5d333e8

Browse files
authored
chore(release-blogs): fix a few issues (#8259)
1 parent ad86795 commit 5d333e8

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

.github/workflows/create-release-post.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ defaults:
2121

2222
permissions:
2323
contents: write
24+
pull-requests: write
2425

2526
jobs:
2627
create-post:
@@ -33,13 +34,16 @@ jobs:
3334
use-version-file: true
3435

3536
- run: node --run scripts:release-post "$VERSION"
37+
working-directory: apps/site
3638
env:
3739
VERSION: ${{ inputs.version }}
3840

3941
- name: Open pull request
4042
uses: gr2m/create-or-update-pull-request-action@b65137ca591da0b9f43bad7b24df13050ea45d1b # v1.10.1
4143
# Creates a PR or update the Action's existing PR, or
4244
# no-op if the base branch is already up-to-date.
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4347
with:
4448
update-pull-request-title-and-body: true
4549
branch: release-${{ inputs.version }}

apps/site/scripts/release-post/index.mjs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import { existsSync, readFileSync } from 'node:fs';
2424
import { writeFile } from 'node:fs/promises';
2525
import { resolve } from 'node:path';
26+
import { parseArgs } from 'node:util';
2627

2728
import handlebars from 'handlebars';
2829
import { format } from 'prettier';
@@ -58,10 +59,20 @@ const ERRORS = {
5859
new Error(`Failed to write Release post: Reason: ${reason}`),
5960
};
6061

62+
const parsedArgs = parseArgs({
63+
options: {
64+
force: {
65+
type: 'boolean',
66+
short: 'f',
67+
},
68+
},
69+
allowPositionals: true,
70+
});
71+
6172
const ARGS = {
6273
CURRENT_PATH: process.argv[1],
63-
SPECIFIC_VERSION: process.argv[2] && process.argv[2].replace('--force', ''),
64-
SHOULD_FORCE: (process.argv[3] || process.argv[2]) === '--force',
74+
SPECIFIC_VERSION: parsedArgs.positionals[0]?.replace(/^v/, ''),
75+
SHOULD_FORCE: Boolean(parsedArgs.values.force),
6576
};
6677

6778
// this allows us to get the current module working directory
@@ -262,9 +273,6 @@ if (import.meta.url.startsWith('file:')) {
262273
.then(renderPost)
263274
.then(formatPost)
264275
.then(writeToFile)
265-
.then(
266-
filepath => console.log('Release post created:', filepath),
267-
error => console.error('Some error occurred here!', error.stack)
268-
);
276+
.then(filepath => console.log('Release post created:', filepath));
269277
}
270278
}

0 commit comments

Comments
 (0)